inline-block是什么鬼?
inline是内联元素,不换行,不能设置宽和高。
block是块元素,换行,可以设置宽和高。
那么有没有既不换行,又能设置宽和高的呢?有,就是inline-block元素。
举个例子
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
div{
width: 100%;
background: yellow;
height: 100px;
text-align: center;
line-height: 100px;
}
a{
color:#fff;
text-decoration: none;
display: inline;
width: 200px;
height: 60px;
line-height: 30px;
background: red;
}
</style>
</head>
<body>
<div>
<a href="">我是a1</a>
<a href="">我是a2</a>
<a href="">我是a3</a>
<a href="">我是a4</a>
</div>
</body>
</html>
结果如下
可以看出,当display为inline时,宽度和高度的设置是没用的,那好,把display改为inline-block。
结果如下
应该还有一种换行,不能设置宽和高不过没啥意义~~~