我一直想问这个问题,例如在覆盖默认hr
外观时,这样做是否更好:
hr {
border: none;
border-top: 1px dashed #000;
}
或这个:
hr {
border-top: 1px dashed #000;
border-left: none;
border-right: none;
border-bottom: none;
}
我一直想问这个问题,例如在覆盖默认hr
外观时,这样做是否更好:
hr {
border: none;
border-top: 1px dashed #000;
}
或这个:
hr {
border-top: 1px dashed #000;
border-left: none;
border-right: none;
border-bottom: none;
}
你的第一个例子:
hr {
border: none;
border-top: 1px dashed #000;
}
相当于:
hr {
border-top: none;
border-right: none;
border-bottom: none;
border-left: none;
border-top: 1px dashed #000;
}
(http://www.w3.org/TR/CSS2/box.html#propdef-border)
因此,可以说您对同一属性应用了两次规则,但这不是值得关注的事情。
两个例子都没有错,但是第一个例子的代码更少,所以我更喜欢第一个。