0

これがインライン要素である場合、スパン要素に高さを指定することは本当にポイントなのだろうか。スパン セレクターの高さにどのような値を設定しても、外観は変わりません。

ここに完全なマークアップとCSSがあります

<!DOCTYPE html>
<html>
    <head>
        <meta charset = "utf-8">
        <title>Relative Positioning</title>
        <style type = "text/css">
           p            
           {
              font-size: 1.3em;
              font-family: verdana, arial, sans-serif; 
           }
           span        
           { 
              color: red;
              font-size: .6em; 
              height: .6em;
           }
           .super      
           { 
              position: relative;
              top: -1ex; 
           }
           .sub        
           { 
              position: relative;
              bottom: -1ex; 
            }
            .shiftleft  
            { 
               position: relative;
               left: -1ex; 
            }
            .shiftright 
            { 
               position: relative;
               right: -1ex; 
            }
        </style>
    </head>
    <body>
       <p>The text at the end of this sentence 
          <span class = "super">is in superscript</span>.
       </p>

       <p>The text at the end of this sentence
          <span class = "sub">is in subscript</span>.
       </p>

       <p>The text at the end of this sentence
          <span class = "shiftleft">is shifted left</span>.
       </p>

       <p>The text at the end of this sentence
          <span class = "shiftright">is shifted right</span>.
       </p>
    </body>
</html>

//トニー

4

2 に答える 2

3

-element が-element (デフォルト<span>)として定義されている限り、高さの値は効果がありません。inline

w3.org 仕様10.5 コンテンツの高さ: '高さ' プロパティ:

このプロパティは、置換されていないインライン要素には適用されません。代わりに使用される規則については、置換されていないインライン要素の高さとマージンの計算に関するセクションを参照してください。

于 2013-09-04T21:37:40.300 に答える
0

Span はインライン要素です。したがって、高さプロパティは使用しません。任意の高さを指定したい場合は、CSS のように使用してくださいdisplay:inline-block!

于 2013-09-05T07:25:36.330 に答える