第一个:
使用列表更方便
<meta charset="UTF-8">
<title>布局案例1</title>
<style>
.pagenation{
width:958px;
height:40px;
border:1px solid #000;
margin:50px auto 0px;
font-size:0px;
text-align: center;
}
.pagenation a{
display:inline-block;
padding:5px 10px;
background-color:lightblue;
font-size:12px;
font-family: "微软雅黑";
text-decoration: none;/*去除文字下划线*/
margin:9px 5px;
color:#333;
}
.pagenation a:hover{
background-color:hotpink;
color:white;
}
.pagenation span{
display:inline-block;
font-size:20px;
}
.menu{
width:958px;
height:40px;
border:1px solid #000;
margin:50px auto 0;
padding:0;
list-style: none;
text-align: center;
line-height: 40px ;
font-size: 0;
}
.menu li{
display:inline-block;
font-size:14px;
}
.menu .line{
color:#333;
margin:0 20px;
}
.menu li a{
font-family: "微软雅黑";
color:#333;
text-decoration: none;
}
.menu li a:hover{
color:pink;
}
</style>
</head>
<body>
<div class="pagenation">
<a href="">上一页</a>
<a href="">1</a>
<a href="">2</a>
<a href="">3</a>
<a href="">4</a>
<span>...</span>
<a href="">17</a>
<a href="">18</a>
<a href="">19</a>
<a href="">20</a>
<a href="">下一页</a>
</div>
<ul class="menu">
<li><a href="">首 页</a></li>
<li class="line">|</li>
<li><a href="">网站介绍</a></li>
<li class="line">|</li>
<li><a href="">网站建设</a></li>
<li class="line">|</li>
<li><a href="">网站建设</a></li>
<li class="line">|</li>
<li><a href="">网站建设</a></li>
<li class="line">|</li>
<li><a href="">网站建设</a></li>
<li class="line">|</li>
<li><a href="">网站建设</a></li>
</ul>
</body>
第二个
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>布局案例2</title>
<style>
.menu{
list-style:none;
background-color: pink;
padding:0;
width:960px;
height:40px;
margin:50px auto 0;
position:relative;
}
.menu li{
float:left;
width:100px;
height:40px;
text-align:center; /*文本居中*/
line-height:40px; /*垂直居中*/
}
.menu li a{
font-size:14px;
font-family: "黑体";
color:#fff;
text-decoration: none;
}
.menu li:hover {
background-color:hotpink;
}
.menu .active{
background-color:hotpink;
}
.menu .new{
width:21px;height:20px;
background:url(xxx.png) no-repeat;
position:absolute;
left:445px;
top:-8px;
}
.menu .new:hover{
background:url(xxx.png) no-repeat;
}
</style>
</head>
<body>
<ul class="menu">
<li class="active"><a href="">首页</a></li>
<li><a href="">网站建设</a></li>
<li><a href="">网站建设</a></li>
<li><a href="">网站建设</a></li>
<li><a href="">网站建设</a></li>
<li><a href="">网站建设</a></li>
<li><a href="">网站建设</a></li>
<li class="new"></li>
</ul>
竖着选项卡
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
*{
margin: 0;
padding: 0;
}
body{
background-color: #dbdbdb;
}
.block{
position: relative;
margin: auto;
width: 1190px;
height: 500px;
}
.block_left{
width: 200px;
height: 500px;
float: left;
margin-right: 10px;
background-color: white;
}
.block_right{
width: 980px;
height: 500px;
background-color: yellow;
float: left;
}
.left_menu>li{
list-style: none;
padding-left: 20px;
font-size: 14px;
line-height: 27.5px;
}
.left_menu>li>a{
text-decoration: none;
color: black;
}
.left_menu>li>span{
display: inline-block;
padding: 0 2px;
font-size: 12px;
}
.left_menu>li>a:hover{
color: red;
}
.left_menu>li:hover{
background-color: #cecece;
}
.li_child{
position: absolute;
left: 200px;
top: 0;
width:990px;
height: 500px;
background-color: white;
border: 1px solid black;
box-sizing: border-box;
display: none;
}
.left_menu>li:hover .li_child{
display: block;
}
</style>
</head>
<body>
<div class="block">
<div class="block_left">
<ul class="left_menu">
<li><a href="#">家用电器</a>
<div class="li_child">1</div>
</li>
<li><a href="#">手机</a><span>/</span><a href="#">运营商</a><span>/</span><span>/</span><a href="#">数码</a>
<div class="li_child">2</div>
</li>
<li><a href="#">电脑</a><span>/</span><a href="#">办公</a>
<div class="li_child">3</div>
</li>
<li><a href="#">家居</a><span>/</span><a href="#">家具</a><span>/</span><a href="#">家装</a><span>/</span><a href="#">厨具</a>
<div class="li_child">4</div>
</li>
<li><a href="#">男装</a><span>/</span><a href="#">女装</a><span>/</span><a href="#">童装</a><span>/</span><a href="#">内衣</a></li>
<li><a href="#">美妆</a><span>/</span><a href="#">个护清洁</a><span>/</span><a href="#">宠物</a></li>
<li><a href="#">女鞋</a><span>/</span><a href="#">箱包</a><span>/</span><a href="#">钟表</a><span>/</span><a href="#">珠宝</a></li>
<li><a href="#">男鞋</a><span>/</span><a href="#">运动</a><span>/</span><a href="#">户外</a></li>
<li><a href="#">房产</a><span>/</span><a href="#">汽车</a><span>/</span><a href="#">汽车用品</a></li>
<li><a href="#">母婴</a><span>/</span><a href="#">玩具乐器</a></li>
<li><a href="#">食品</a><span>/</span><a href="#">酒类</a><span>/</span><a href="#">生鲜</a><span>/</span><a href="#">特产</a></li>
<li><a href="#">艺术</a><span>/</span><a href="#">礼品鲜花</a><span>/</span><a href="#">农资绿植</a></li>
<li><a href="#">医药保健</a><span>/</span><a href="#">计生情趣</a></li>
<li><a href="#">图书</a><span>/</span><a href="#">文娱</a><span>/</span><a href="#">电子书</a></li>
<li><a href="#">机票</a><span>/</span><a href="#">酒店</a><span>/</span><a href="#">旅游</a><span>/</span><a href="#">生活</a></li>
<li><a href="#">理财</a><span>/</span><a href="#">众筹</a><span>/</span><a href="#">白条</a><span>/</span><a href="#">保险</a></li>
<li><a href="#">安装</a><span>/</span><a href="#">维修</a><span>/</span><a href="#">清洗保养</a></li>
<li><a href="#">工业品</a></li>
</ul>
</div>
<div class="block_right"></div>
</div>
</body>
横选项卡
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
* {
margin: 0;
padding: 0;
}
.block {
margin: auto;
width: 500px;
height: 400px;
position: relative;
}
.menu {
font-size: 0;
}
.menu > li {
width: 100px;
font-size: 16px;
list-style: none;
display: inline-block;
text-align: center;
line-height: 35px;
height: 35px;
border: 1px solid silver;
box-sizing: border-box;
cursor: pointer;
}
.menu > li>span{
position: relative;
z-index: 2;
display: block;
width: 100px;
height: 35px;
box-sizing: border-box;
}
.menu > li:hover {
color: red;
border-color: red red white red;
}
.menu > li:hover span{
border-bottom: 1px solid white;
}
.menu_c {
position: absolute;
display: none;
left: 0;
top: 35px;
width: 500px;
height: 365px;
border: 1px solid red;
text-align: left;
box-sizing: border-box;
}
.menu > li:hover .menu_c {
display: block;
}
</style>
</head>
<body>
<div class="block">
<ul class="menu">
<li>
<span>卡一</span>
<div class="menu_c">卡一</div>
</li>
<li>
<span>卡二</span>
<div class="menu_c">卡二</div>
</li>
<li>
<span>卡三</span>
<div class="menu_c">卡三</div>
</li>
<li>
<span>卡四</span>
<div class="menu_c">卡四</div>
</li>
<li>
<span>卡五</span>
<div class="menu_c">卡五</div>
</li>
</ul>
</div>
</body>