CSS中需要什么将属性传递给所有的孩子,而不仅仅是直接的孩子?如何使属性适用于所有的后代,而不仅仅是直接的孩子?
.post>img {
height: 50%;
width: 100%;
}
<div class="post">
<img src="http://cdn1.theodysseyonline.com/files/2015/06/21/635704919336245232-967016789_Hair.jpg" />
<!--This works, appropriately sizing the image. However, if I nest the image, the properties
seem to disappear:-->
<a href="http://theodysseyonline.com/ui/4-reasons-why-should-totally-have-crush-bernie-sanders/111812">
<img src="http://cdn1.theodysseyonline.com/files/2015/06/21/635704919336245232-967016789_Hair.jpg" />
</a>
</div>
<!--The sizing on the image disappears :(How can I make all img descendants of
.post inherit .post>img's properties?-->
第二图像,其嵌套在a
标签,不继承.post>img
的属性。
我认为这是因为它不是一个直接的孩子。我如何强制所有img
后裔.post
继承.post>img
propeties?