gpt4 book ai didi

css - LESS:如何确定宽度:15% of (100% - @SideBarWidth)

转载 作者:太空宇宙 更新时间:2023-11-03 18:06:45 24 4
gpt4 key购买 nike

如何计算需要为 (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%)”。

最佳答案

乘法需要用到小数<​​/p>

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

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

关于css - LESS:如何确定宽度:15% of (100% - @SideBarWidth),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24511932/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com