css - 在 Stylus mixin 中连接变量

标签 css stylus

我正在尝试制作一个 mixin 来生成一些带有变量的样式,我想连接两个变量,但我无法让它工作。这是一个例子:

centerSprite($icon)
    margin-top -(($ico_+$icon+_height) / 2)
    margin-left -(($ico_+$icon+_width) / 2)

我有一个带有图标高度和宽度的变量,我想将名称放在 mixin 的参数中以获取该变量并进行操作...

提前致谢!

最佳答案

我不知道为什么(也许是一个错误?)但是当你在函数内的属性值中的括号前有一个减号时,stylus 无法编译:

此代码无法编译:

centerSprite()
    margin-top -((5 + 10 + 3) / 2)

body
    centerSprite()

但是这个没有函数编译:

 body
     margin-top -((5 + 10 + 3) / 2)

而且我发现如果您在该属性也适用于函数后使用冒号:

手写笔

centerSprite()
    margin-top: -((5 + 10 + 3) / 2)

body
    centerSprite()

CSS

body {
    margin-top: -9;
}

关于css - 在 Stylus mixin 中连接变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45752401/

相关文章:

css - 手写笔查找哈希名称

node.js - 在 express 4 中使用手写笔中间件,SyntaxError

html - HTML 表单的跨浏览器兼容性问题

html - div 中的图像在图像下方有额外的空间

node.js - 如何在 Express 中使用 Jeet?

css - @extend 之后声明的类

css - 我可以使用 Express.js 动态渲染 css 吗?

html - 单击 Bootstrap 4 navbar-toggler 使动画内容比屏幕宽

javascript - jquery 基本内容 slider

html - 如何将 FontAwesome 字符添加到所有 block 引用的开头?