我正在尝试创建一个仅针对我的控件的 CSS 重置。所以 HTML 看起来像这样:
<body>
<img class="outterImg" src="sadkitty.gif" />
<div id="container" class="container">
<img class="innerImg" src="sadkitty.gif" />
<div class="subContainer">
<img class="innerImg" src="sadkitty.gif" />
</div>
</div>
<img class="outterImg" src="sadkitty.gif" />
</body>
CSS是我遇到的麻烦,但我目前正在处理这个:
img
{
// Bad style declarations for the entire page
border: solid 3px red;
width: 50px;
}
.container img, .container div, .container etc.
{
// Style reset for specific elements within my control "container"
border: solid 3px blue;
width: 100px;
}
.innerImg img
{
// The target style for the specific class/element within the control
border: solid 3px green;
width: 200px;
}
问题是“.innerImg img”没有像我期望的那样覆盖“.container img”。那么,重置“容器”元素中所有元素的样式,然后在该元素中的类上放置样式的最佳方法是什么?