如何使用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>热门推荐
2 圆圆的祝福语简短
10 公司春节祝福语和简短
11 国庆求婚祝福语简短精辟
12 孙子结婚祝福语大全简短
13 38节贺卡简短祝福语
14 婆婆生日祝福语简短的
15 他舅生日祝福语简短
16 端午发给客户祝福语简短
17 双节祝福语简短唯美
18 考试祝福语日文简短版