第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

添加textpath成功后 text的寬高全部坍縮為0 請(qǐng)問(wèn)大佬們,這個(gè)怎么解決

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8" />

<title>textPath</title>

</head>

<body>

<label>Path:</label>

<form>

<select id="text-path-select">

<option value="none">none</option>

<option value="#path1">path1</option>

<option value="#path2">path2</option>

<option value="#path3">path3</option>

</select>

</form>

<svg width="800" height="600"? xmlns="http://:wwww.w3.org/2000/svg">

<path id="path1" d="M 100? 200 Q 200 100? 300 200 T 500 200" stroke="rgb(0,255,0)" fill="none"></path>

<path id="path2" d="M100,300l100-50,200,100,100,-50 " stroke="rgb(255,0,0)" fill="none"></path>

<path id="path3" d="M100,400A400,300,0,0,0,500,400 " stroke="blue" fill="none"></path>

<text id="text" x="100" y="100" stroke="" fill="" font-size="20px" font-family="Microsoft YaHei">

Text path scripting <tspan id="tspan">動(dòng)態(tài)使用路徑文本</tspan>

</text>

</svg>

<script type="text/javascript">

// 命名空間

var SVG_NS = "http://:wwww.w3.org/2000/svg";

var XLINK_NS= "http://:wwww.w3.org/1999/xlink";

var select = document.getElementById('text-path-select');

var text = document.getElementById('text');

var tspan = document.getElementById('tspan');



function addTextPath() {

var textPath = document.createElementNS(SVG_NS,'textPath');

while(text.firstChild){

textPath.appendChild(text.firstChild);

}

text.appendChild(textPath);

}



function setTextPath(path) {

var textPath? = text.firstChild;??

textPath.setAttributeNS(XLINK_NS,'xlink:href',path);

var pathElment = document.querySelector(path);

tspan.setAttribute('fill',pathElment.getAttribute('stroke'));

}


function removeTextPath() {

var textPath = text.firstChild;

while(textPath.firstChild){

text.appendChild(textPath.firstChild);

}

text.removeChild(textPath);

tspan.removeAttribute('fill');

}



select.addEventListener("input",function () {

var value = select.value;

if (text.firstChild.tagName && text.firstChild.tagName.toLowerCase() == 'textpath') {

if (value == 'none') removeTextPath();

else setTextPath(value);

}else{

if (value != 'none') {

addTextPath();

setTextPath(value);

}

}

});

</script>

</body>

</html>


https://img1.sycdn.imooc.com//5b0a49dc0001e06c13490596.jpg



正在回答

1 回答

老哥。。你的坍縮這個(gè)詞用的很是玄妙,你出現(xiàn)這種問(wèn)題的原因其實(shí)很明顯...

你的namespace鏈接寫(xiě)錯(cuò)了,應(yīng)該是'

舉報(bào)

0/150
提交
取消

添加textpath成功后 text的寬高全部坍縮為0 請(qǐng)問(wèn)大佬們,這個(gè)怎么解決

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)