【发布时间】:2020-07-19 14:21:06
【问题描述】:
如何为名为“mp_m_blurb_underline_sliding”的类的元素应用相同的样式,并应用一些元素明智的样式而不重复整体?
这里我需要为下划线的颜色应用额外的样式。
.mp_m_blurb_underline_sliding h4 {
display: inline-block;
position: relative;
padding-bottom: 5px;
font-size: 5px;
font-weight: 600;
-webkit-transition: all .5s ease-out;
-moz-transition: all 0.5s ease-out;
-ms-transition: all 0.5s ease-out;
-o-transition: all 0.5s ease-out;
transition: all 0.5s ease-out;}
.mp_m_blurb_underline_sliding p {
padding-top: 10px;}
.mp_m_blurb_underline_sliding h4:hover {
color: #2ea3f2;}
【问题讨论】:
-
同一类但风格不同?您需要一个附加标准来决定应用哪种样式。
-
.mp_m_blurb_underline_sliding h4, .another_style1, .another_style2, { ... } .another_style1 { 颜色:红色; } .another_style2 {颜色:绿色; }
-
使用 CSS 自定义属性/变量将是一种现代解决方案。