CSS预处理之Less_html/css_WEB-ITnose
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了CSS预处理之Less_html/css_WEB-ITnose,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1652字,纯文字阅读大概需要3分钟。
内容图文
趁这几天有空,了解一下css预处理的知识less简介
Less 是一个Css 预编译器,意思指的是它可以扩展Css语言,添加功能如允许变量(variables),混合(mixins),函数(functions) 和许多其他的技术,让你的Css更具维护性,主题性,扩展性。
Less 可运行在 Node 环境,浏览器环境和Rhino环境.同时也有3种可选工具供你编译文件和监视任何改变。
语法
变量
声明一个变量:
@width:100px;.test { width: @width;}
.border { border: 1px solid red;}.test { width: @box_width; height: 100px; background: #ccc; .border; //直接混合使用}
正常写法
.test { font-size: 10px;}. test a { color: red;}
less 写法:
.test { font-size: 10px;a { color: red; }}
同样可以包含伪类:
.test { font-size: 10px; a { &:hover { color: blue; } color: red; }}
@width: 5px;.test { width: @width + 10; //15px}
less能推断此处的单位
.border_radius(@width:5px) { //5px是可选参数,表示默认值 -webkit-border-radius: @width; -moz-border-radius: @width; -ms-border-radius: @width; border-radius: @width;}.test { .border_radius(20px); }
.bundle { .button { display: block; border: 1px solid black; background-color: grey; &:hover { background-color: white } }}//现在如果我们想在 .header a 中混合 .button 类,那么我们可以这样做:.header a { color: orange; .bundle > .button; }
@var: red;.page { #header { color: @var; // white } @var: white;}
.test { width: ~'calc(300px - 30px)';}
//不会被编译css /**/会被编辑到css
更多使用语法,请查看less中文网。 http://lesscss.net/ 个人github博客:aralic.github.io
内容总结
以上是互联网集市为您收集整理的CSS预处理之Less_html/css_WEB-ITnose全部内容,希望文章能够帮你解决CSS预处理之Less_html/css_WEB-ITnose所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。