SVG.text自动换行

1、(20180530)目前查到的资料,说 SVG自身 还没有 文字自动换行的功能

2、资料:

  2.1、xml - Auto line-wrapping in SVG text - Stack Overflow.html(https://stackoverflow.com/questions/4991171/auto-line-wrapping-in-svg-text

  2.2、请问SVG text怎么设置字体大小?怎么换行? - LeslieHoward的回答 - SegmentFault 思否.html(https://segmentfault.com/q/1010000008426252/a-1020000008428672

  2.3、大概类似的代码为:

<svg xmlns="http://www.w3.org/2000/svg" style="outline: 1px solid red;margin: 50px;">
    <switch>
        <foreignObject x="20" y="0" width="150" height="200" style="outline: 1px solid blue;">
            <p xmlns="http://www.w3.org/1999/xhtml">Text goes here, Text goes here, Text goes here, Text goes here</p>
        </foreignObject>
                
        <text x="20" y="20">Your SVG viewer cannot display html.</text>
    </switch>
</svg>

 

3、测试(20180619)

<switch>
    <foreignObject x="0" y="0" width="1500" height="2000" style="outline: 1px solid blue;">
        <p xmlns="http://www.w3.org/1999/xhtml">Text goes here, Text goes here, Text goes here, Text goes here.东<br/><br/><br/><br/><br/><br/>04</p>
        <font xmlns="http://www.w3.org/1999/xhtml" face="黑体" color="red"><br/><br/><br/><br/><br/><br/>04</font>
        <html xmlns="http://www.w3.org/1999/xhtml"><br/><br/><br/><br/><br/><br/>04</html>
东
怡
变
04
    </foreignObject>
    
    <text x="20" y="20">Your SVG viewer cannot display html.</text>
</switch>

  ZC:(1)、文字外面不加 <p/>或<font/>或<html/>等等 的话,没有办法识别<br/>(直接用 回车 也不行)

  ZC:(2)、<p/>、<font/>、<html/> 的属性“xmlns="http://www.w3.org/1999/xhtml"” 是必须的,如果没有 则文字是看不见的

4、

5、

 

转载于:https://www.cnblogs.com/h5skill/p/9111435.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值