[英]nth-child, change style of every other div with class name
I have got some elements on my page, they should all be styled the same except for every other one, where I just want to change some styling. 我的页面上有一些元素,除了其他元素(我只想更改某些样式)外,所有元素的样式都应相同。
Here is the CSS which I was hoping would select the div inside the stack of different elements: 这是我希望在不同元素堆栈中选择div的CSS:
.stagger_reviews[class=inner]:nth-child(2n+2) {
background-color:#003;
}
Here is the HTML: 这是HTML:
<div class="stagger_reviews">
<!-- Later use PHP to load reviews, CSS should switch the images from left to right -->
<article class="container box style1">
<a style="background-image:url(images/blank-user.jpg); " href="#" class="image fit"></a>
<div class="inner">
<header>
<h2>Martyn Ball</h2>
</header>
<p>
I found this service on a Google Search, didn't expect it to be so great!
</p>
</div>
</article>
<article class="container box style1">
<a style="background-image:url(images/blank-user.jpg); " href="#" class="image fit"></a>
<div class="inner">
<header>
<h2>Martyn Ball</h2>
</header>
<p>
I found this service on a Google Search, didn't expect it to be so great!
</p>
</div>
</article>
</div>
As you can see I just want to adjust the one div inside each article which has the class name inner
. 如您所见,我只想调整每篇文章的一个div,该文章的类名是
inner
。 And maybe some other elements as well but once I have this working I can do that. 也许还有其他一些要素,但是一旦我进行了这项工作,我就可以做到。
The style isn't being applied to the second inner
div, I have made about 4 copies of the article and none are being changed. 该样式未应用于第二个
inner
div,我已完成了约4篇文章的复制,并且均未更改。
这是解决方案,我将第n个孩子放在错误的位置。
.stagger_reviews > article:nth-child(2n+2) div[class=inner]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.