如何使用JavaScript设置元素周围轮廓的宽度?
若要设置轮廓宽度,请使用outlineWidth属性。您可以尝试运行以下代码以使用JavaScript设置元素周围的轮廓宽度-
示例
<!DOCTYPE html>
<html>
<head>
<style>
#box {
width: 450px;
background-color: orange;
border: 3px solid red;
margin-left: 20px;
}
</style>
</head>
<body>
<p>Click below to add Outline Width.</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 Width</button>
<br>
<script>
function display() {
document.getElementById("box").style.outlineColor = "#5F5F5F";
document.getElementById("box").style.outlineStyle = "solid";
document.getElementById("box").style.outlineWidth = "7px";
}
</script>
</body>
</html>热门推荐
10 年底拜年祝福语大全简短
11 新年祝福语简短句子
12 祝福语简短七夕
13 酒店客人祝福语简短
14 送花祝福语简短十一朵
15 关于早晨的祝福语简短
16 阳历新年祝福语大全 简短
17 小朋友祝福语简短的话
18 公司年终晚会祝福语简短