在这里, div定义应该得到与图像相同的高度。但我得到了额外的 4 个像素的高度。有谁知道为什么会这样?
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link href="StyleSheet.css" rel="stylesheet" />
</head>
<body>
<div class="container">
<img src="29.jpg" />
<div class="definition">
DEFINITION GOES HERE
</div>
</div>
</body>
</html>
body {
margin: 0;
}
html, body {
height: 100%;
}
.container {
position: absolute;
}
.definition {
position: absolute;
top: 0;
width: 100%;
height: 100%;
background-color: red;
opacity: 0;
}
.definition:hover {
opacity: 1;
transition: 2s ease-in;
}