默认情况下,图片是以基线对齐的,也就是下方会留有一条白色的边
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
<style type="text/css">
div {
border: 2px solid #000;
}
</style>
</head>
<body>
<div>
<img src="images/video.jpg" />yg
</div>
</body>
</html>
修改方式一:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
<style type="text/css">
img {
/*也可以写成vertical-align: bottom;,一般比较常用的写法是vertical-align: middle;*/
vertical-align: middle;
}
div {
border: 2px solid #000;
}
</style>
</head>
<body>
<div>
<img src="images/video.jpg" />yg
</div>
</body>
</html>
修改方式二:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
<style type="text/css">
img {
/* vertical-align: middle; */
display: block;
}
div {
border: 2px solid #000;
}
</style>
</head>
<body>
<div>
<img src="images/video.jpg" />
</div>
</body>
</html>