3

以下のコードを参照してください。2番目の「content-block」内でH2タグのフォントサイズを変更する必要があります。Divタグまたはh2タグ自体を直接変更することはできません。変更できるのは、h2タグの下のコンテンツのみです。

<div class="content-block">
<h2>Title here</h2>
<p>this is some text.</p>
</div>

<div class="content-block">
<h2>Modify This title only</h2>
<p>this is some more text.</p>
<style>## I can add CSS here ##</style>
</div>

編集:変更したいものより上にある「content-block」divの数がわかりません。ページからページへと変化します。(ショッピングカート)

どうすれば可能ですか?

ありがとう。

4

2 に答える 2

3
.content-block + .content-block h2 {/* your css */}

デモ:http ://dabblet.com/gist/4013393

+これは、隣接兄弟セレクターと呼ばれるものです。

于 2012-11-04T20:01:30.487 に答える
0

CSS3 :nth-child() セレクターを使用して、問題が解決することを願っています

ここで例を確認してください: http://www.w3schools.com/cssref/sel_nth-child.asp

于 2012-11-05T06:25:49.193 に答える