css - 如何在 less mixin 中访问特定的类属性?

标签 css less mixins less-mixins

我有.aClass

.aClass {
 width: 20px;
 height: 20px;
}

在 .anotherClass 中,我想根据 .aClass 中的宽度属性值计算宽度值。

.anotherClass {
 width: .aClass.width
}

上面的例子是行不通的。

我在 less 文档中找不到任何内容。有什么办法吗?

最佳答案

在代码顶部声明变量

@width: 10px

然后,

.aClass {
 width: @width;
 height: 20px;
}

.anotherClass {
 width: @width;
}

关于css - 如何在 less mixin 中访问特定的类属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12004601/

相关文章:

python - 从 Python 中的常用函数中提取混入

html - 如何以百分比宽度和高度在图像上垂直和水平居中文本?

ruby 与类方法、实例方法和类变量混合

html - 这可以在没有表格或 JavaScript 的情况下完成吗 : 100% height wills remaining height of container

html -::before 和::after 内容总是在 <p> 内容之上和之下?

css - PhpStorm LESS Watcher 配置

asp.net-mvc-4 - 无点@import

javascript - 将 Mixins 与我的主干 View 一起使用时遇到问题

css - Sass:扩展嵌套选择器

html - 下拉子菜单中每列只有三个元素