我有一段HTML代码,我坚持使用。
如何将此文本的第一部分设置为20px的字体大小,将<br>
标记后的文本设置为15px的字体大小?
或者,如果我完全错误的话,如果不将它们放在不同的标签中,我该怎么做呢
<p id="losinfo"> Los Santos: a sprawling sun-soaked metropolis full of
self-help gurus, starlets and fading celebrities, once the envy of the
Western world, now struggling to stay afloat in an era of economic
uncertainty and cheap reality TV <br><br> Our largest open world yet
- by far - and spanning vastly diverse cultural and geographical areas,
the entire world of Grand Theft Auto V is open from the very beginning
of the game to explore. Visitors to the greater metropolis of Los Santos
and the countryside of Blaine County will encounter faded celebrities,
meth heads, party people, violent gangs, hikers, bikers and every other
manner of colorful denizen. You'll be able to traverse everywhere from
the tops of the mountains, through the streets of Los Santos and to the
depths of the ocean floor</p>
答案 0 :(得分:11)
<p id="losinfo">Los Santos: <span id='secondText'> a sprawling sun-soaked ...</span></p>
然后在css中以不同的方式设置#losinfo
和#secondText
。
答案 1 :(得分:1)
在您想要的部分20px
周围使用div,并在您想要的15px
部分周围使用另一个div。然后使用类设置这些div并在css中设置font-size
。
答案 2 :(得分:1)
尝试
CSS
p#losinfo {
font-size:20px;
}
p#losinfo span {
font-size:15px;
}
HTML
<p id="losinfo"> Los Santos: a sprawling sun-soaked metropolis full of self-help gurus, starlets and fading celebrities, once the envy of the Western world, now struggling to stay afloat in an era of economic uncertainty and cheap reality TV <br><br>
<span>Our largest open world yet - by far - and spanning vastly diverse cultural and geographical areas, the entire world of Grand Theft Auto V is open from the very beginning of the game to explore. Visitors to the greater metropolis of Los Santos and the countryside of Blaine County will encounter faded celebrities, meth heads, party people, violent gangs, hikers, bikers and every other manner of colorful denizen. You'll be able to traverse everywhere from the tops of the mountains, through the streets of Los Santos and to the depths of the ocean floor</span></p>
答案 3 :(得分:1)
我遇到了这个问题,因为我试图弄清楚如何在同一行文本中更改字体。瞧,跨度也适用于此。为简化起见,这里没有id:
<p>regular text <span style="font-size: 30pt;">new size text</span></p>
<p>old font <span style="font-family: courier;">new font</span></p>
答案 4 :(得分:0)
你的问题有点不清楚 你的意思是这样吗?
<p id="losinfo">
<span style="font-size:20px;">Los Santos</span>
<span style="font-size:15px;">: a sprawling sun-soaked metropolis [...]</span>
</p>