如何使用JavaScript设置元素周围轮廓的颜色?
若要设置轮廓颜色,请使用outlineColor属性。您可以尝试运行以下代码,以使用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 Color.</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 Color</button>
<br>
<script>
function display() {
document.getElementById("box").style.outline = "thick solid";
document.getElementById("box").style.outlineColor = "#5F5F5F";
}
</script>
</body>
</html>热门推荐
2 孙媳妇祝福语简短
10 中班入学祝福语简短大全
11 送离别同事简短祝福语
12 新婚祝福语大全简短经典
13 女性生日祝福语简短优美
14 双十一祝福语大全简短
15 对学姐的简短祝福语
16 表妹结婚祝福语简短藏语
17 公司年终晚会祝福语简短
18 撩妹生日祝福语简短