如何用 JavaScript 設定文字的陰影效果?
若要設定陰影效果,請在 JavaScript 中使用 textShadow 屬性。
示例
你可以嘗試執行以下程式碼,以透過 JavaScript 返回文字的陰影效果 −
<!DOCTYPE html>
<html>
<body>
<button onclick = "display()">Set Text Shadow</button>
<div id = "myID">
This is Demo Text! This is Demo Text! This is <br>This is Demo Text! This is Demo Text! This is Demo Text! This is Demo Text!<br> This is Demo Text!<br> This is Demo Text! This is Demo Text! This is Demo Text! This is Demo Text!
</div>
<script>
function display() {
document.getElementById("myID").style.textShadow = "2px 2px 2px #ff0000,20px 5px 2px #F1F1F1";
}
</script>
</body>
</html>
廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP