css属性的书写顺序

1.建议顺序

  1. 布局定位属性:display / position / float / clear / visibility / overflow(建议display第一个写,因为关系到模式)
  2. 自身属性:width / height / margin / padding / border / background
  3. 文本属性:color / font / text-decoration / text-align / vertical-align / white-space / break-word
  4. 其他属性(css3):content / cursor / border-radius / box-shadow / text-shadow / background:linear-gradient …

2.示例

.box{
   //1.布局
    display: block;
    position: relative;
    float: left;
    
    //2.自身属性
    width: 100px;
    height: 100px;
    margin: 0 10px;
    padding: 20px 0;

    //3.文本属性
    font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif;
    color: #333;
    
    //4.其他属性(css3)
    background: rgba(0, 0, 0, .5);
    border-radius: 10px;
}

猜你喜欢

转载自blog.csdn.net/m0_51487301/article/details/124134712