[英]css more efficient ? changing color on arrow and header
So I have three boxes and each box <h2>
header area has a different color. 因此,我有三个框,每个框
<h2>
标头区域都有不同的颜色。
Is there a way I can make the arrow below the <h2>
basically get the color that is selected without making the code too long? 有没有一种方法可以使
<h2>
下面的箭头基本上获得所选择的颜色而又不会使代码太长?
Is there a more efficient way of doing this than making 3 different css codes and 3 different arrow codes for each box? 是否有比每个框制作3个不同的CSS代码和3个不同的箭头代码更有效的方法?
Basically I want each <h2>
and arrow to be the same color but with each color selected. 基本上,我希望每个
<h2>
和箭头都具有相同的颜色,但是选择了每种颜色。
example: http://jsfiddle.net/mGn9S/ 例如: http : //jsfiddle.net/mGn9S/
<div class="service">
<div class="service-img">
<img src="images/img.png" />
</div>
<!--end image-->
<h2 class="service-style color_service">test1</h2>
<div class="service-text">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua Lorem ipsum dolor sit amet…</p>
</div>
</div>
perfect example in the jsfiddle is box three "Test 3" jsfiddle中的完美示例是第三个方框“ Test 3”
To make this more efficient, use CSS preprocessors like LESS or SASS . 为了提高效率,请使用CSS预处理程序,如LESS或SASS 。
CSS Solution: CSS解决方案:
Try: 尝试:
Add different classes and give border-colors. 添加不同的类并指定边框颜色。
HTML: HTML:
<div class="service-text text1">...
<div class="service-text text2">...
<div class="service-text text3">...
CSS: CSS:
.service-text.text1:before{border-top-color:#2ecc71}
.service-text.text2:before{border-top-color:#e67e22}
.service-text.text3:before{border-top-color:#3498db}
.service-text:before{border-top: 30px solid;}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.