代码之家  ›  专栏  ›  技术社区  ›  singingfish

CSS可以根据前面的标题类为我提供段落样式吗?

  •  2
  • singingfish  · 技术社区  · 16 年前

    <h2 class="interviewer">Alice: [00:00:00]</h2>
    <p>Is it ok if I ask you a question now?</p>
    
    <h2 class="interviewee">Bob: [00:00:03]</h2>
    <p>Sure go ahead.</p>
    

    3 回复  |  直到 14 年前
        1
  •  4
  •   Williham Totland    16 年前

    您可以使用以下兄弟组合子:+

    h2.interviewer + p { /* style goes here */ }

        2
  •  3
  •   Samir Talwar PruthviRaj Reddy    16 年前

    当然:

    h2.interviewer + p {
        color: red;
    }
    

    div :

    <h2 class="interviewer">Alice: [00:00:00]</h2>
    <div>
        <p>Is it ok if I ask you a question now?</p>
        <p>More text here.</p>
    </div>
    
    <h2 class="interviewee"> class="interviewee">Bob: [00:00:03]</h2>
    <div>
        <p>Sure go ahead.</p>
    </div>
    

    h2.interviewer + div {
        color: red;
    }
    
        3
  •  3
  •   Stephan Muller    13 年前

    顺便说一句,有更好的HTML元素可以显示对话,比如新引入的 <dialog> 标签

    http://www.quackit.com/html_5/tags/html_dialog_tag.cfm

    <对话框> 元素从未进入HTML5。它不存在。

    推荐文章