亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

怎么在svg里設置文字的center位置

怎么在svg里設置文字的center位置

holdtom 2019-03-28 18:17:49
怎么在svg里設置文字的center位置
查看完整描述

2 回答

?
湖上湖

TA貢獻2003條經驗 獲得超2個贊

給你做了一個小demo。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

<html>

     

    <head>

        <style>

        div { width: 300px; height: 150px; background: #f06; font: bold 150% sans-serif; text-shadow: 0 1px 2px rgba(0,0,0,.5); overflow: hidden; resize: both; color: white; } 

        svg { width: 100%; height: 100%; pointer-events: none; }

        text { text-anchor: middle; pointer-events: auto; fill: currentColor; } 

        p { font: italic 100% Georgia, serif; }

        </style>

    </head>

    <body>

        <div>

            <svg>

                <text x="50%" y="50%" dy=".3em">居中文字</text></svg>

        </div>

    </body>

 

</html>


 


查看完整回答
反對 回復 2019-03-31
?
米琪卡哇伊

TA貢獻1998條經驗 獲得超6個贊

示例
<?xml version="1.0" encoding="iso-8859-1"?>
<svg width="800" height="600">
<text style="fill:red;font-size:24pt" x="100" y="100";text-align:center>Hello World!</text>
</svg>

 


查看完整回答
反對 回復 2019-03-31
  • 2 回答
  • 0 關注
  • 1603 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號