LESS 中停止次数可变的线性梯度? (或萨斯)
这是我想用 Less 抽象的 CSS。在这种情况下,有 4 个站点。但我还有另外一堂课,有 10 站。如何使用可变数量的参数?
我在文档中看到 @arguments
,但正如您所注意到的,语法有所不同:一些规则使用连续的所有参数,其他规则将它们成对分组:color-stop(x% ,#y)
。
如果您知道 Sass 中的解决方案,建议它,我可以切换到它。
.action {
background: -moz-linear-gradient(top, #6db3f2 0%, #54a3ee 50%, #3690f0 51%, #1e69de 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#6db3f2), color-stop(50%,#54a3ee), color-stop(51%,#3690f0), color-stop(100%,#1e69de)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #6db3f2 0%,#54a3ee 50%,#3690f0 51%,#1e69de 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #6db3f2 0%,#54a3ee 50%,#3690f0 51%,#1e69de 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, #6db3f2 0%,#54a3ee 50%,#3690f0 51%,#1e69de 100%); /* IE10+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6db3f2', endColorstr='#1e69de',GradientType=0 ); /* IE6-9 */
background: linear-gradient(top, #6db3f2 0%,#54a3ee 50%,#3690f0 51%,#1e69de 100%); /* W3C */background: linear-gradient(top, #1e5799 0%,#2989d8 14%,#207cca 84%,#7db9e8 100%); /* W3C */
}
Here's a CSS that I want to abstract with Less. In this case, there are 4 stops. But I have another class with 10 stops. How can I use variable number of arguments?
I see @arguments
in the docs, but as you can notice, the syntax differs: some rules use all the arguments in a row, others group them in pairs: color-stop(x%, #y)
.
If you know a solution in Sass, suggest it, I can switch to it.
.action {
background: -moz-linear-gradient(top, #6db3f2 0%, #54a3ee 50%, #3690f0 51%, #1e69de 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#6db3f2), color-stop(50%,#54a3ee), color-stop(51%,#3690f0), color-stop(100%,#1e69de)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #6db3f2 0%,#54a3ee 50%,#3690f0 51%,#1e69de 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #6db3f2 0%,#54a3ee 50%,#3690f0 51%,#1e69de 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, #6db3f2 0%,#54a3ee 50%,#3690f0 51%,#1e69de 100%); /* IE10+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6db3f2', endColorstr='#1e69de',GradientType=0 ); /* IE6-9 */
background: linear-gradient(top, #6db3f2 0%,#54a3ee 50%,#3690f0 51%,#1e69de 100%); /* W3C */background: linear-gradient(top, #1e5799 0%,#2989d8 14%,#207cca 84%,#7db9e8 100%); /* W3C */
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己的解决方案,使用修改后的文件 bourbon 项目:
_linear-gradient.scss
用法(screen.sass):
我如何使用 django-compressor:
模板:
My own solution, using a modified file from bourbon project:
_linear-gradient.scss
usage (screen.sass):
How I configured Sass with django-compressor:
a template: