CSS: vertical-align






<!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 {
font-size: 20px;
}
.parent {
width: 800px;
height: 100px;
border: 1px solid red;
}
.foo {
vertical-align: middle;
height: 50px;
width: 50px;
display: inline-block;
background-color: plum;
position: relative;
}
img {
vertical-align: bottom;
width: 40px;
height: 40px;
}
.span-1 {
/* vertical-align: middle; */
}
.bar {
/* vertical-align: middle; */
display: inline-block;
width: 60px;
height: 60px;
background-color: palegreen;
}
</style>
</head>
<body>
<div class="parent">
<img src="bb.png" alt="">
<span class="span-1">the quick brown foxp</span>
<div class="foo">
</div>
<span class="span-2">jump over the lazy dog.</span>
<div class="bar"></div>
</div>
</body>
</html>
所有元素会按照其vertical-align对齐, 最高元素的顶部于父元素顶部重合

浙公网安备 33010602011771号