【问题标题】:How to set two different font sizes in the same <p>如何在同一个<p>中设置两种不同的字体大小
【发布时间】:2013-09-02 11:44:43
【问题描述】:

我有一段 HTML 代码被我卡住了。 如何将此文本的第一部分设置为 20 像素的字体大小,将 &lt;br&gt; 标记后的文本设置为 15 像素的字体大小?

或者如果我做的完全错了,如果不把它们放在不同的标签中,我该怎么做

<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>

【问题讨论】:

    标签: html css font-size paragraph


    【解决方案1】:
    <p id="losinfo">Los Santos: <span id="secondText"> a sprawling sun-soaked ...</span></p>
    

    然后在 css 中以不同的方式设置 #losinfo#secondText

    【讨论】:

      【解决方案2】:

      在你想要的部分周围使用一个 div 20px,在你想要的部分周围使用另一个 div 15px 是我会做的。然后用类设置这些 div 并在 css 中设置font-size

      【讨论】:

      • 你应该使用&lt;span&gt; 而不是&lt;div&gt;
      【解决方案3】:

      试试

      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>
      

      【讨论】:

        【解决方案4】:

        你的问题有点不清楚。
        你的意思是这样的吗?

        <p id="losinfo">
        <span style="font-size:20px;">Los Santos</span>
        <span style="font-size:15px;">: a sprawling sun-soaked metropolis [...]</span>
        </p>
        

        【讨论】:

          【解决方案5】:

          我遇到了这个问题,因为我试图弄清楚如何在同一行文本中更改字体。瞧,span 也适用于此。为简化起见,这里没有 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>
          

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 2015-09-08
            • 2012-07-05
            • 2011-11-16
            • 2018-07-08
            • 1970-01-01
            • 2011-03-05
            • 2011-09-27
            相关资源
            最近更新 更多