如何使用 JavaScript 在单条声明中设置所有的 outline 属性?
要在一份声明中设置所有 outline 属性,请使用 outline 属性。它设置以下属性:outline-width、outline-style 和 outline-color。
范例
你可以尝试运行以下代码来了解如何处理 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>
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP