轮廓线
1.轮廓线:显示在边框外部的线段,不占用宽高,使用的方法和
border一样
outline-width: 20px;
outline-style: dashed;
outline-color: blue;
2. 轮廓线的偏移量(离边框的偏移量)
outline-offset: -10px;
3.如果使用边框那么会占用宽高,影响到布局,
使用轮廓线不会占用宽高
outline: 10px solid black;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body{
margin: 0;
}
#div1{
width: 200px;
height: 200px;
border: 20px solid red;
padding: 20px;
margin: 30px;
/* 轮廓线:显示在边框外部的线段,不占用宽高,使用的方法和
border一样 */
outline-width: 20px;
outline-style: dashed;
outline-color: blue;
/* 轮廓线的偏移量(离边框的偏移量) */
outline-offset: -10px;
}
.box{
width: 1000px;
height: 300px;
background-color: red;
font-size: 0;
}
.item{
font-size: 16px;
width: 250px;
height: 250px;
background-color: blue;
display: inline-block;
/* 如果使用边框那么会占用宽高,影响到布局,
使用轮廓线不会占用宽高 */
outline: 10px solid black;
}
.item:nth-child(2){
background-color: green;
}
.item:nth-child(3){
background-color: gold;
}
.item:nth-child(4){
background-color: grey;
}
/* input自带有轮廓线 */
input{
border: 0;
/* 获取焦点时有轮廓 取消轮廓线*/
outline: 0;
}
button{
border: solid 1px red;
}
button:focus{
outline: 10px solid blueviolet;
}
</style>
</head>
<body>
<div id="div1">
内容区内容区内容区内容区内容区内容区内容区内容区内容区内容区
</div>
<div class="box">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<input type="text">
<button>按钮</button>
</body>
</html>