【问题标题】:Match a tag element inside a div with specific class in CSS将 div 中的标签元素与 CSS 中的特定类匹配
【发布时间】:2014-02-14 07:33:48
【问题描述】:

我想将 div 中的 h1h2p 标签与 apply_specific_styling 类匹配

代码如下:

<div class="apply_specific_styling">
 <h1>Header 1</h1>
 <h2>Header 2</h2>
 <p>Some text here...</p>
</div>

您如何使用纯 CSS 实现这一目标。我用谷歌搜索没有成功...

谢谢!

【问题讨论】:

    标签: html css css-selectors


    【解决方案1】:

    你可以这样做:

    .apply_specific_styling h1,
    .apply_specific_styling h2,
    .apply_specific_styling p {
    }
    

    我建议填写basic CSS tutorial,因为这些选择器非常基础。当您遇到困难时,我们很乐意提供帮助,但我们无法教您 CSS。这不是合适的地方。

    【讨论】:

      【解决方案2】:

      您可以像这样为这些元素设置 CSS:

      .apply_specific_styling h1,
      .apply_specific_styling h2,
      .apply_specific_styling p {
        /* your CSS here */
        color: yellow;
      }
      

      例如View this fiddle

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2019-12-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-11-30
        • 2022-10-02
        相关资源
        最近更新 更多