[英]CSS :first-child rule
HTML is as follows HTML如下
<div class="box">
<a href="images/about_1.jpg">
<img src="images/about_1_thumb.jpg" class="float-left">
</a>
<a href="images/about_2.jpg">
<img src="images/about_2_thumb.jpg" class="float-left">
</a>
</div>
CSS is as follows CSS如下
div.box img.float-left{
float:left;
display:inline;
}
div.box a img.float-left:first-child{
margin-right: 5px;
}
Trying to get the margin-right rule to appear only on the image inside the first anchor tag. 试图使右边距规则仅出现在第一个锚标记内的图像上。 Anybody see what I'm doing incorrectly?
有人看到我做错了吗?
您对第一个孩子的css调用应位于共享最高的标签(在本例中为a标签)上,而不应位于共享最高的嵌套元素中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.