gpt4 book ai didi

html - 第 n 个 child ,用类名改变每个其他 div 的样式

转载 作者:行者123 更新时间:2023-11-28 07:22:04 25 4
gpt4 key购买 nike

我的页面上有一些元素,除了每个其他元素外,它们的样式都应该相同,我只想更改一些样式。

这是我希望在不同元素堆栈中选择 div 的 CSS:

.stagger_reviews[class=inner]:nth-child(2n+2) {
background-color:#003;
}

这是 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>

如您所见,我只想调整每篇文章中具有类名 inner 的一个 div。也许还有其他一些元素,但一旦我完成了这项工作,我就可以做到。

样式没有应用到第二个 inner div,我已经复制了大约 4 份文章,没有一个被更改。

最佳答案

这是解决方案,我把第n个 child 放错了地方。

.stagger_reviews > article:nth-child(2n+2) div[class=inner]

关于html - 第 n 个 child ,用类名改变每个其他 div 的样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32037808/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com