stylus语法

stylus 支持缩进写法

h1
    color: #ffaff;

变量

/*定义变量*/
maincolor = #090032
siteWidth = 1024px
borderStyle = dotted

body
    color maincolor
    border 1px borderStyle mainColor
    max-width siteWidth

嵌套写法

nav {
    ul {
            margin : 0;
           padding:0;
      }
     li {
            display: inline-block;
       }
     a {
            display:block;
            padding:6px 12px;
           text-decoration:none;
       }
}
 
转为css后格式为
nav ul{}
nav li{}
nav a{}

运算符

margin:(14px/2);
top:50px+100px;
right:80*10%

 

样式表文件合并导入

/*base.styl*/

background:#000;
font-famliy:'Microsoft YaHei';



导入base.css或 .styl文件 到bbb.styl
@import "base.css";
@import "filename.styl";

body
    color:red
    font-size:18px

样式继承

当我们需要为多个元素定义相同样式的时候,我们可以考虑使用继承的做法.
.common {
  border:1px solid #ccc;
  padding:10px;
  color:#333
}

.success {
  @extend .common;
  color:#0ff;
}
.error{
  @extend .common;
  color:#f00;
}

混入(函数)

error(borderWidth = 2px) {
    border:borderWidth solid #f00;
    color:#f00
}
.generic-error{
    padding:20px;
    margin:4px;
    error();
}
.login-error{
    left:12px;
    position:absolute;
    top:20px;
    error(5px);
}

弹性列 样式计算器

弹性列
siteWidth =1024px;
gutterWidth=20px;
sidebarWidth=300px;
body
    margin:0 auto;
    width:siteWidth;
.content
    float:left;
    width:siteWidth - (sidebarWidth+gutterWidth);

.sidebar
    float:left;
    margin-left:gutterWidth;
    width:sidebarWidth;

 Font-face

 

@font-face
    font-family bors
    font-style normal
    src url(fonts/bors/boraz.ttf)

.bs 
    font-family bors

 

@media

 

@media screen and (min-width:600) 
    
    body
        background:#000

 

@keyframes

@keyframes myanimate 
     0%
        width:50px
      
     100%
         width:120px

 

转载于:https://www.cnblogs.com/hnshi/p/7640625.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值