gpt4 book ai didi

css - 将 LESS Mixin 转换为 Stylus Mixin

转载 作者:太空宇宙 更新时间:2023-11-04 02:46:01 25 4
gpt4 key购买 nike

我有以下 Less Mixin 可以帮助我制作响应式的东西:

.mobile-first(@minWidth, @rulesSet) {
@media only screen and (min-width: @minWidth) {
@rulesSet();
}
}

我想将它转换成 Stylus Mixin,我有这段代码,但它不起作用:

.mobile-first($minWidth, $rulesSet) 
@media only screen and (min-width: $minWidth)
$rulesSet();

我是这样使用它的:

body
font-family Helvetica, Arial, sans-serif
font-size 100%
line-height 1.5em
color #2a2a2a
-webkit-font-smoothing antialiased
.min-width(1200px
background-color pink

希望大家能帮帮我。

问候!

最佳答案

你需要在这里使用 block mixins。像这样:

// This mixin accepts any block of code if called with + sign.
// The provided block is stored in "block" variable
// and expanded if used inside an interpolation ({}).
mobile-first($minWidth)
@media only screen and (min-width: $minWidth)
{block}

body
font-family Helvetica, Arial, sans-serif
font-size 100%
line-height 1.5em
color #2a2a2a
-webkit-font-smoothing antialiased
// calling it with a block
+mobile-first(1200px)
background-color pink

关于css - 将 LESS Mixin 转换为 Stylus Mixin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33838105/

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