行块盒
display:inline-block 的盒子
- 不独占一行
- 盒模型中所有尺寸都有效。
空白折叠
空白折叠,发生在行盒(行块盒)内部 或 行盒(行块盒)之间。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.pager a {
border: 1px solid #e1e2e3;
text-decoration: none;
color: #38f;
width: 34px;
height: 34px;
display: inline-block;
text-align: center;
line-height: 34px;
}
.pager a:hover {
border-color: #38f;
background: #f2f8ff;
}
.pager a.selected {
border: none;
color: #000;
background: initial;
}
</style>
</head>
<body>
<div class="pager">
<a href="">1</a>
<a href="">2</a>
<a href="" class="selected">3</a>
<a href="">4</a>
<a href="">5</a>
<a href="">6</a>
<a href="">7</a>
<a href="">8</a>
<a href="">9</a>
<a href="">10</a>
</div>
</body>
</html>
问题:
行块盒之前的间隙哪里来的?
a之间有很多空格,会折叠成一个空格。
如何排成一排?
1.去除换行符,将所有的a排在一行;
2.将a设置为浮动;
3.将div的display设置为flex。