<tspan>
        
        
          
                Baseline
                
                  Widely available
                
                 *
              
        
        
        
          
                
              
                
              
                
              
        
        
      
      This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
* Some parts of this feature may have varying levels of support.
<tspan> は SVG の要素で、 <text> 要素内にあるサブテキストやその他の <tspan> 要素を定義します。これにより、必要に応じてサブテキストのスタイルや位置を調整することができます。
メモ:
<tspan> 要素は、既定では折り返されません。折り返すには、CSS の white-space プロパティを使用してスタイルを設定する必要があります。
例
<svg viewBox="0 0 240 40" xmlns="http://www.w3.org/2000/svg">
  <style>
    text {
      font: italic 12px serif;
    }
    tspan {
      font: bold 10px sans-serif;
      fill: red;
    }
  </style>
  <text x="10" y="30" class="small">
    You are
    <tspan>not</tspan>
    a banana!
  </text>
</svg>
属性
- x
- 
テキストのベースラインの開始点の X 座標です。 値の型: (<length> | <percentage>) のリスト; 既定値: 0; アニメーション: 可
- y
- 
テキストのベースラインの開始点の Y 座標です。 値の型: (<length> | <percentage>) のリスト; 既定値: 0; アニメーション: 可
- dx
- 
テキストの位置を直前のテキスト要素から水平方向にずらします。 値の型: (<length> | <percentage>) のリスト; 既定値: none; アニメーション: 可 
- dy
- 
テキストの位置を直前のテキスト要素から垂直方向にずらします。 値の型: (<length> | <percentage>) のリスト; 既定値: none; アニメーション: 可 
- rotate
- 
それぞれの文字の向きを回転します。文字ごとに個別に回転させることができます。 値の型: <list-of-number>; 既定値: none; アニメーション: 可 
- lengthAdjust
- 
テキストを textLength属性で定義された幅に合わせるために伸縮する方法です。 値の型:spacing|spacingAndGlyphs; 既定値:spacing; アニメーション: 可
- textLength
- 
テキストを伸縮して合わせる幅です。 値の型: <length> | <percentage>; 既定値: none; アニメーション: 可 
使用コンテキスト
仕様書
| Specification | 
|---|
| Scalable Vector Graphics (SVG) 2> # TextElement> | 
ブラウザーの互換性
Loading…