HTML代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>商品列表</title>
<link rel="stylesheet" type="text/css" href="css/post4.css">
</head>
<body>
<!--第一行-->
<div class="tab-top">
全部商品分类
</div>
<div class="tab-grandpa">
<!--下面的内容-->
<div class="tab-parent">
<ul class="tab-child">
<li class="tab">
<a href="#">家用、电器 ></a>
<div class="content">1</div>
</li>
</ul>
<ul class="tab-child">
<li class="tab">
<a href="#">电脑、办公 ></a>
<div class="content">2</div>
</li>
</ul>
<ul class="tab-child">
<li class="tab">
<a href="#">电脑、办公 ></a>
<div class="content">3</div>
</li>
</ul>
<ul class="tab-child">
<li class="tab">
<a href="#">电脑、办公 ></a>
<div class="content">4</div>
</li>
</ul>
<ul class="tab-child">
<li class="tab">
<a href="#">电脑、办公 ></a>
<div class="content">5</div>
</li>
</ul>
<ul class="tab-child">
<li class="tab">
<a href="#">电脑、办公 ></a>
<div class="content">6</div>
</li>
</ul>
<ul class="tab-child">
<li class="tab">
<a href="#">电脑、办公 ></a>
<div class="content">7</div>
</li>
</ul>
<ul class="tab-child">
<li class="tab">
<a href="#">电脑、办公 ></a>
<div class="content">8</div>
</li>
</ul>
</div>
</div>
</body>
</html>
CSS代码
html,body{
font-family: '新宋体';
}
.tab-top{
color: white;
font-size: 20px;
background-color: red;
text-align: center;
line-height: 30px;
height: 30px;
width: 200px;
border: 1px solid #ffffff;
position: relative;
}
.tab-grandpa{
float: top;
border: 1px solid red;
position: relative;
height: 200px;
}
.tab-grandpa .tab-parent{
margin: 0px;
padding: 0px;
font-size: 20px;
float: top;
border: 1px solid #ffffff;
height: 20px;
}
.tab-grandpa .tab-parent .tab-child{
margin: 0px;
padding: 0px;
list-style: none;
}
.tab-grandpa .tab-parent .tab-child .tab{
margin: 0px;
padding: 0px;
border: 0px;
float: top;
}
.tab-grandpa .tab-parent .tab-child .tab a{
color: white;
margin: 0px;
padding: 0px;
background-color: red;
height: 25px;
width: 100px;
border: 1px solid #fff;
text-align: center;
line-height: 25px;
text-decoration: none;
border-right: 1px solid red;
display: inline;
}
.tab-grandpa .tab-parent .tab-child .tab:hover a{
color: red;
background-color: white;
border-right: 1px solid #fff;
}
.tab-grandpa .tab-parent .tab-child .tab:hover .content{
display: inline;
}
.tab-grandpa .tab-parent .tab-child .tab .content{
/*背景色*/
background-color: lightsteelblue;
width: 200px;
height: 199px;
border: 1px solid;
border-left: none;
color: red;
font-size: 100px;
position: absolute;
left: 124px;
top: 0px;
text-align: center;
line-height: 200px;
display: none;
}
效果图: