【问题标题】:CSS - Changing one indirect child of parent with specific classCSS - 使用特定类更改父级的一个间接子级
【发布时间】:2015-01-22 14:50:48
【问题描述】:

我正在尝试使用类.category-member 访问所有article 标记的h1 子级,而不会影响其任何其他子级。到目前为止,我只成功地影响了.blog-content,并且对h1 没有运气。此外,它正在 WordPress 中使用,所以我希望在不向 h1 添加类的情况下执行此操作,这样任何添加的博客文章都将仅根据其父类别类进行着色。

提前致谢!

<article id="post-3107" class="post-3107 post type-post status-publish format-standard has-post-thumbnail hentry category-member span6 blog-article grid normal">                    
  <div class="row-fluid">
  <div class="row-fluid">
    <div class="span12">
      <div class="content post_format_standart">
        <div class="top_c ">
          <h1><a href="http://wholeworldwater.dev:8080/another-test-post/">ANOTHER TEST POST</a></h1>
        </div>
        <div class="blog-content">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam venenatis dolor eget est imperdiet efficitur. Donec et mollis sapien. Nam rhoncus urna dolo
        </div>
      </div>
    </div>
  </div>
</article>

【问题讨论】:

  • .category-member .top_c + h1{ } 选择 .top_c 之后的 h1
  • 但是&lt;h1&gt;.top_c 之内,而不是“在它之后”。
  • 我认为他的意思是category-member .top_c &gt; h1{ }

标签: html css wordpress class parent-child


【解决方案1】:

使用.category-member h1 { ... ... } 之类的选择器。这将选择 h1 的所有内容,其父级具有 category-member 类。

【讨论】:

    【解决方案2】:

    谢谢大家 - 意识到我的具体问题是我忽略了h1a 标签。不过,你们都在现场!

    .category-member .top_c > h1 a{
      color: #d9382c;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-25
      • 2017-06-01
      • 2014-03-24
      • 1970-01-01
      • 2019-12-02
      • 1970-01-01
      相关资源
      最近更新 更多