仿小米侧边栏导航
渲染:鼠标进入,背景颜色会变成红色,鼠标退出又变回原来的颜色。
代码:
<!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>
</head>
<style>
/* text-decoration: none; 去掉a标签的下划线
display: inline-block; 行内块
*/
.box {
width: 200px;
height: 550px;
background: #2c505f;
line-height: 50px;
color: white;
margin-left: 30px;
}
/* text-indent: 30px; 文本缩进属性是用来指定文本的第一行的缩进。 */
a {
text-decoration: none;
display: block;
color: white;
text-indent: 30px;
font-size: 14px;
}
a:hover {
background: red;
}
</style>
<body>
<div class="box">
<a href="#">手机 电话卡</a>
<a 电视 href="#">电视 盒子</a>
<a href="#">笔记本 显示器</a>
<a href="#">家电 插线板</a>
<a href="#">出现 穿戴</a>