Ski*_*33k 5 css subclassing css-cascade
我为我的网站制作了一组按钮,我需要一些专业的见解.
为了减少CSS膨胀,我想将我的按钮子类化为不同的颜色,ex .button.blue.
将来会出现以下问题吗?(假设我没有制作.blue的类)我是否必须使用像.button.button-blue这样的东西?
.button {
display:inline-block;
padding: 9px 18px;
margin: 20px;
text-decoration: none;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
text-align: center;
background: #FFE150;
}
.button.blue {
background: #49b8e7;
border:1px solid #54abcf;
border-bottom:1px solid #398fb4;
color:#FFF
text-shadow: 0 1px 0 rgba(255,255,255, 0.5);
}
.header{
height: 50px;
}
.header.blue {
background: blue;
color: #fff;
}
Run Code Online (Sandbox Code Playgroud)
假设您希望它们像这样工作,那么多类的所有功能都可以正常工作:
<div class="button blue">
Will use .button and .button.blue
</div>
<div class="button">
Will only use .button
</div>
<div class="header blue">
Will use .header and .header.blue
</div>
<div class="header">
Will only use .header
</div>
<div class="blue">
Will use neither of the .blue declarations because it doesn't contain header or button.
</div>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12942 次 |
| 最近记录: |