如何使用JavaScript在单个声明中设置所有大纲属性?
要在一个声明中设置所有大纲属性,请使用outline属性。它设置以下属性:轮廓宽度,轮廓样式和轮廓颜色。
示例
您可以尝试运行以下代码以了解如何使用大纲属性-
<!DOCTYPE html>
<html>
<head>
<style>
#box {
border: 2px dashed blue;
}
</style>
</head>
<body>
<div id="box">This is a div.</div>
<br>
<button type="button" onclick="display()">Click to set Outline</button>
<script>
function display() {
document.getElementById("box").style.outline = "5px solid red";
}
</script>
</body>
</html>