首页 > 解决方案 > 如何通过使用 css 选择器从父 div 访问子 div 来为子 div 应用不显示

问题描述

我正在为我使用 Css,代码变得动态,所以有人可以解释如何通过使用 css 选择器访问父 div 来为子 div 应用 display none。对我来说,代码是动态的,所以我是代码的形象在此处输入图像描述

所以从我的代码中,如何为这个 div 应用 display none --->

<div class="jsx-674079454 topbar"></div>

所以我对 Image 的问题是为了更好地理解。

如果您有任何问题,请告诉我。

标签: css

解决方案


第一种方法是最简单的直接使用类如:

.topbar {
  display: none;
}
<div id='_next'>
  <div class='randomoijosj'>
    <div class='randomoijokpokpokosj call'>
      <div class='randomoijosjytfty topbar'>hideme</div>
      <div class='randomoijosjtyf main'></div>
    </div>
  </div>
</div>

或者您可以使用>如下选择器:

#_next>div>div>div {
  display: none;
}
<div id='_next'>
  <div class='randomoijosj'>
    <div class='randomoijokpokpokosj call'>
      <div class='randomoijosjytfty topbar'>hideme</div>
      <div class='randomoijosjtyf main'></div>
    </div>
  </div>
</div>


推荐阅读