【发布时间】:2017-04-22 21:41:21
【问题描述】:
我有一组 div,其中包含一些要显示的信息。 如何更改每个偶数容器内链接文本的颜色?
.container {
height: 200px;
margin-top: 5px;
}
.container:nth-child(even){
background-color: green;
}
.container:nth-child(odd) {
background-color: skyblue;
}
<div class="container">
Company website: <a href="abc.html">ABC</a>
My Profile: <a href="user.html">User1</a>
<button>Edit</button>
</div>
<div class="container">
Company website: <a href="abc.html">ABC</a>
My Profile: <a href="user.html">User1</a>
<button>Edit</button>
</div>
<div class="container">
Company website: <a href="abc.html">ABC</a>
My Profile: <a href="user.html">User1</a>
<button>Edit</button>
</div>
<div class="container">
Company website: <a href="abc.html">ABC</a>
My Profile: <a href="user.html">User1</a>
<button>Edit</button>
</div>
【问题讨论】:
-
一个{颜色:蓝色; }
-
给每个 a 标签起名字然后使用它..
标签: html css css-selectors pseudo-class