国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

CSS 規(guī)則在沒有類的情況下應(yīng)用,為什么?
P粉795311321
P粉795311321 2023-09-04 13:26:05
0
1
649
<p>我定義CSS規(guī)則:</p> <pre class="brush:php;toolbar:false;">.info-specs h2, h3, h4, h5 { font-size: 1.5em; text-transform: none; }</pre> <p>這應(yīng)該只適用于類為“info-specs”的元素中的 h5。然而,經(jīng)過檢查,我發(fā)現(xiàn)其他h5元素也在使用這個(gè)規(guī)則。為什么? 下面是一個(gè)示例:</p> <p> <pre class="snippet-code-css lang-css prettyprint-override"><code>.info-specs h2, h3, h4, h5 { font-size:5em; text-transform: none; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code><h5>mytest </h5></code></pre> </p>
P粉795311321
P粉795311321

全部回復(fù)(1)
P粉308089080

瀏覽器的 CSS 解釋器將查找任何 h3、h4h5 元素,并且僅查找 h2 它將查看它是否在 .info-specs 內(nèi)。逗號(hào)或分組選擇器將逗號(hào)分隔的所有內(nèi)容視為單獨(dú)的選擇。

您的問題的可能解決方案是:

/* These select for any h2, h3, h4 and h5 within .info-specs */

.info-specs h2,
.info-specs h3,
.info-specs h4,
.info-specs h5
{
  text-decoration: underline;
}

/* These select for ant h2, h3, h4 and h5 that are direct chldren of .info-specs */
.info-specs > h2,
.info-specs > h3,
.info-specs > h4,
.info-specs > h5
{
  color: red;
}
<div class="info-specs">
  <p>In this example the headings within inf-specs will all be underlined but only the headings that are direct children of info-specs will be coloured red.</p>
  <h2>Heading 2</h2>
  <h3>Heading 3</h3>
  <div>
    <h3>Heading 3 in another div</h3>
  </div>
  <h4>Heading 4</h4>
  <h5>Heading 5</h5>
</div>
最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板