代码:
<!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>
/* 1.把a转化为块级元素 */
a {
display: block;
width: 322px;
height: 52px;
text-decoration: none;
background-color: #535758;
color: #fff;
text-indent: 2em;
font-size: 14px;
}
/* 2.鼠标经过更换背景颜色 */
a:hover {
background-color: #fc6e00;
}
</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>
运行结果
代码
<!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>
div {
width: 200px;
height: 40px;
background-color: pink;
line-height: 40px;
}
</style>
</head>
<body>
<div>我要垂直居中</div>
</body>
</html>