【问题标题】:LESS: How to determine width: 15% of (100% - @SideBarWidth)LESS:如何确定宽度:15% of (100% - @SideBarWidth)
【发布时间】:2014-07-01 22:11:20
【问题描述】:

如何计算需要为 (100% - @SideBarWidth) 的 15% 的 DIV 的宽度,其中 @SideBarWidth 是我的侧边栏的宽度?为了以另一种方式描述我的问题,我希望获得我页面内容区域(不包括侧栏区域)的百分比。这可以用 CSS 和 LESS 计算吗?

我目前拥有的 LESS:

@sidebarWidth: 250px;

.myDiv
{
    position: fixed;
    left: @sidebarWidth;
    width: calc(15% * (100% - @sidebarWidth));
}

编译时正在生成:

.myDiv
{
    position: fixed;
    left: 250px;
    width: calc(-2250%);
}

不希望的宽度为“calc(-2250%)”。

【问题讨论】:

标签: css less


【解决方案1】:

乘法时需要使用小数

编辑: 对不起,你必须在计算之外做乘法

 width: calc(100% - @sidebarWidth) * .15;

【讨论】:

  • 这会产生:width: 'calc(-22.5%);'
猜你喜欢
  • 1970-01-01
  • 2020-12-22
  • 2016-08-09
  • 2015-02-04
  • 2013-10-09
  • 2013-08-28
  • 2014-06-13
  • 1970-01-01
  • 2014-11-30
相关资源
最近更新 更多