<div class="big_box">haha</div>
<div class="small_box">haha</div>
Run Code Online (Sandbox Code Playgroud)
这(类型1)似乎可行: -
.big_box, .small_box { border:1px solid #ccc; /* lengthy attributes*/}
.big_box { width:150px; height:150px; }
.small_box { height:140px; width:140px; }
Run Code Online (Sandbox Code Playgroud)
这(类型2)也有效: -
.big_box { border:1px solid #ccc; width:150px; height:150px; /* same lengthy attributes*/}
.small_box { border:1px solid #ccc; width:150px; height:150px; /* same lengthy attributes* }
Run Code Online (Sandbox Code Playgroud)
当然,类型2很长并且对于大多数常见属性(具有相同值)重复
,使用类型1是否有任何问题?
(或者只是允许这样做?)
PS类型3也有效(但我觉得难以管理)...... 如果
<div class="box big">haha</div>
Run Code Online (Sandbox Code Playgroud)
和
.box { border:1px solid #ccc; /* lengthy attributes*/}
.big { width:150px; height:150px;}
Run Code Online (Sandbox Code Playgroud) css ×1