Style textShadow 屬性

定義和用法
textShadow 屬性設(shè)置或返回一個(gè)或多個(gè)的文本陰影效果。
語(yǔ)法
設(shè)置 textShadow 屬性:
Object.style.textShadow="none|h-shadow v-shadow blur color|inherit"
注意:textShadow 屬性向文本附加一個(gè)或多個(gè)的陰影。該屬性是一個(gè)逗號(hào)分隔的陰影列表,每個(gè)值由 2 或 3 個(gè)長(zhǎng)度值和一個(gè)可選的顏色指定。省略的長(zhǎng)度為 0。
返回 textShadow 屬性:
Object.style.textShadow
值 | 描述 |
---|---|
none | 默認(rèn)。沒(méi)有陰影繪制。 |
h-shadow | 必需。水平陰影的位置。可使用負(fù)值。 |
v-shadow | 必需。垂直陰影的位置??墒褂秘?fù)值。 |
blur | 可選。模糊距離。 |
color | 可選。陰影的顏色。在 CSS 顏色值 中尋找可能的顏色值的完整列表。 |
inherit | textShadow 屬性的值從父元素繼承。 |
瀏覽器支持
所有主要瀏覽器都支持 textShadow 屬性,除了 Internet Explorer。
實(shí)例
實(shí)例
給文本添加陰影:
<html>
<head>
<script>
function displayResult()
{
document.getElementById("p1").style.textShadow="5px 5px 1px #ff0000";
}
</script>
</head>
<body>
<p id="p1">This is some text.</p>
<br>
<button type="button" onclick="displayResult()">Add shadow to text</button>
</body>
</html>
<head>
<script>
function displayResult()
{
document.getElementById("p1").style.textShadow="5px 5px 1px #ff0000";
}
</script>
</head>
<body>
<p id="p1">This is some text.</p>
<br>
<button type="button" onclick="displayResult()">Add shadow to text</button>
</body>
</html>
嘗試一下 ?

更多建議: