【问题标题】:How to change style of no classed dev?如何改变无分类开发的风格?
【发布时间】:2022-08-11 19:13:12
【问题描述】:

我有这个嵌套的 html

<div class=\"x\">
  <div>.....</div>
  <div> The One i want to change it\'s style</div>
</div>

我想访问第二个兄弟姐妹,其父级是类 \"x\" 的 div

我尝试使用

.x div:nth-child(2) {
  padding-bottom: 30px;
  margin-bottom: 30px;
}

但没有工作

    标签: html css reactjs


    【解决方案1】:

    .x div:nth-child(1) {
      padding-bottom: 30px;
      margin-bottom: 30px;
      background:green
    }
    <div class="x">
      <div>some text</div>
      <div> The One i want to change it's style</div>
    </div>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-30
      • 2019-05-08
      相关资源
      最近更新 更多