我想让鼠标悬停的时候边上的边框出现,可是为什么悬停的时候里面的内容也动了。
边框是存在占位的,可以预先设置border透明色,悬停的时候更改边框颜色
<!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>
#container {
width: 100px;
height: 100px;
background-color: red;
border: 1px solid transparent;
}
#container:hover {
/* border: 1px solid blue; */
border-color: blue;
}
</style>
</head>
<body>
<div id="container">我是内容</div>
</body>
</html>
边框也是有占像素的,如果你里面内容太挤的话加边框是会有扩张