我需要将字体大小增加到H1(标题)后面的每个段落的每个第一个字母的200%。
即
<h1> This is a header </h1>
<p>The first 'T' in this paragraph needs to be set to 200%</p>
<ul>
<li>Random list item 1</li>
<li>Random list item 2</li>
</ul>
<p>The first 'T' in this paragraph does NOT need to be set to 200% as it doesn't follow an H1</p>
我最接近的是使用p :: first-letter {font-size:200%;}但这显然不起作用,因为它选择了每个段落的第一个字母。我一直在谷歌搜索并试图找出如何选择那些现在永远跟随H1的那些。我很感激帮助。
答案 0 :(得分:9)
您可以使用h1 + p::first-letter
:
h1 + p::first-letter {font-size: 200%;}
<h1> This is a header </h1>
<p>The first 'T' in this paragraph needs to be set to 200%</p>
<ul>
<li>Random list item 1</li>
<li>Random list item 2</li>
</ul>
<p>The first 'T' in this paragraph does NOT need to be set to 200% as it doesn't follow an H1</p>
+
仅选择adjacent sibling(在这种情况下,只有<p>
immediatley跟随<h1>
。)
答案 1 :(得分:0)
试试这个,它可能对你有帮助
h1~p:第一个字母{font-size:200%;}
答案 2 :(得分:0)
span{
font-size: 3rem;
}
<h1><span>f</span>irst text styled font</h1>