CSS 样式的参考嵌套 DIV
使用 Elementor 我有一个当前的 HTML 结构,如下所示;
<div class="carousel-post">
<div class="elementor-element-overlay">
<div class="elementor-widget-container">
<div class="elementor-posts-container">
</div>
</div>
</div>
</div>
我需要引用“elementor-posts-container”类,因此,我添加了“carousel-post”类。
在我的CSS中,我想将“elementor-posts-container”显示为FLEX,但是,只有这个位于“carousel-post”下的DIV。
CSS
.carousel-post, .elementor-posts-container
上面的内容有效,但针对所有 .elementor-posts-container
Using Elementor I have a current HTML structure as per the below;
<div class="carousel-post">
<div class="elementor-element-overlay">
<div class="elementor-widget-container">
<div class="elementor-posts-container">
</div>
</div>
</div>
</div>
I need to reference the class "elementor-posts-container" therefore, I have added class "carousel-post".
In my CSS I want to display "elementor-posts-container" as FLEX however, only this DIV which is under "carousel-post".
CSS
.carousel-post, .elementor-posts-container
The above works but targets all .elementor-posts-container
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
***** 只是一个解释 *****
添加此作为答案,因为我无法添加格式。
应该是
. Remove the comma.
当代码为
时,带有逗号(,)这意味着匹配两者中的任何一个。
当您删除逗号 (,) 时,表示匹配父级中的子级。 -->>> 这将符合您的用例
要获得直接父子关系的直接匹配(当您将来需要它时),请执行
。这将直接匹配“.carousel-post”中的所有“.elementor-posts-container”div。
***** 编辑 *****
这不起作用:
上面的代码意味着,“.carousel-post”内的所有“.elementor-posts-container”应该是“display flex”。
***** Just an Explanation *****
Adding this as an answer since I am not able to add formatting.
It should be
. Remove the comma.
When the code is
, with the comma (,) it means match either of the two.
When you remove the comma (,), it means match the child within the parent. -->>> This will match your usecase
To get a direct match of the direct parent-child relationship (when you need it in the future), do
. This matches all the ".elementor-posts-container" divs directly within ".carousel-post".
***** EDIT *****
Doesn't this work:
The above code means, all ".elementor-posts-container" inside ".carousel-post" should be "display flex".