如何实现SVG 1.2 Tiny textArea?

Eld*_*ley 9 html5 svg

我最近在互联网上浏览了SVG本地有一个textArea(我可能需要这个用于文本包装目的)

我使用了这个例子并在Chrome5里面的Chrome5元素中进行了测试,但它不会显示textArea元素,任何人都知道如何正确实现SVG textArea?或者是否可能不支持SVG 1.2 tiny?(我只使用通常的SVG 1.1)

Rob*_*son 12

检查UA是否支持http://www.w3.org/Graphics/SVG/feature/1.2/#TextFlow功能字符串,如果有,则显示SVG textArea,否则在foreignObject内显示html textarea,例如

<switch>
    <g requiredFeatures="http://www.w3.org/Graphics/SVG/feature/1.2/#TextFlow">
        <textArea width="200" height="300">whatever</textArea>
    </g>
    <foreignObject width="200" height="300">
        <textArea xmlns="http://www.w3.org/1999/xhtml" style="width: 200px;height: 300px">otherwise</textArea>
    </foreignObject>
</switch>
Run Code Online (Sandbox Code Playgroud)

  • 注意:您还需要在foreignObject元素上指定宽度和高度,以使其可见. (4认同)
  • requiredFeatures字符串是正确的,但http://www.w3.org/TR/SVGTiny12/feature.html#specific是一个更好的参考. (2认同)