首先是显示模块的转换:
把行内元素转换为块儿级元素: display: block;
把块元素转换为行内元素 display: inline;
效果如下:
代码如下:
<!DOCTYPE html>
<html la ng="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>
a {
display: block;
width: 230px;
height: 40px;
background-color: rgb(83, 87, 88);
font-size: 14px;
color: white;
text-indent: 2em;
text-decoration: none;
margin: auto;
line-height: 40px;
}
a:hover {
background-color: orange;
}
</style>
</head>
<body>
<a href="">手机 电话卡</a>
<a href="">电视 盒子</a>
<a href="">笔记本 平板</a>
<a href="">出行 穿戴</a>
<a href="">智能 路由器</a>
<a href="">健康 儿童</a>
<a href="">耳机 音响</a>
</body>
</html>