如何使用 JavaScript 在一個宣告中設定所有輪廓屬性?
要設定輪廓屬性,請使用 outline 屬性。它允許你設定輪廓的顏色、樣式和偏移。
示例
你可以嘗試執行以下程式碼,使用 JavaScript 在一個宣告中設定所有輪廓屬性 −
<!DOCTYPE html>
<html>
<head>
<style>
#box {
width: 450px;
background-color: orange;
border: 3px solid red;
}
</style>
</head>
<body>
<p>Click below to add Outline.</p>
<div id="box">
<p>This is a div. This is a div. This is a div. This is a div. This is a div.</p>
<p>This is a div. This is a div. This is a div. This is a div. This is a div.</p>
<p>This is a div. This is a div. This is a div. This is a div. This is a div.</p>
</div>
<br>
<button type="button" onclick="display()">Set Outline</button>
<br>
<script>
function display() {
document.getElementById("box").style.outline = "thick solid #5F5F5F";
}
</script>
</body>
</html>
廣告
資料結構
網路
關係資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP