如何使用JavaScript设置元素周围的轮廓样式?
若要设置轮廓样式,请使用outlineStyle属性。轮廓可以是实线,点线,虚线等。
示例
您可以尝试使用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 Style.</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 Style</button>
<br>
<script>
function display() {
document.getElementById("box").style.outlineColor = "#5F5F5F";
document.getElementById("box").style.outlineStyle = "solid";
}
</script>
</body>
</html>热门推荐
10 高考毕业祝福语简短励志
11 新娘妈妈祝福语简短的
12 新房落成的简短祝福语
13 看病住院的祝福语简短
14 生日祝福语简短独特格式
15 送花祝福语简短十一朵
16 高考给舍友祝福语简短
17 要过年了祝福语简短
18 中考正能量祝福语简短