1.构建一个导航栏显示页
使用浮动布局来显示下列效果
1.设置所有元素浮动
2.使用盒模型调整元素距离
<!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>导航栏</title>
<style>
ul,li{
padding:0;
margin: 0;
/* 清楚列表样式 */
list-style: none;
float:left;
}
.first{
color: gray;
margin: 10px 5px 10px 0;
}
.item{
margin: 10px 20px;
padding: 2px 5px;
}
.active{
background-color: red;
color: #fff
}
</style>
</head>
<body>
<ul>
<li class="first">难度:</li>
<li class="item">全部</li>
<li class="item">初级</li>
<li class="item active">中级</li>
<li class="item">高级</li>
</ul>
</body>
</html>
2.构建一个购物车显示页
使用绝对与相对定位来显示下列效果:
1.圆角图形的应用
2.绝对定位与相对定位的使用
<!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>构建一个购物车显示页</title>
<style>
.cart{
width: 150px;
height: 35px;
border: 1px solid #999;
background-color: #ccc;
text-align: center;
line-height: 35px;
font-size: 14px;
position: relative;
}
.count{
width: 16px;
height: 16px;
background-color: red;
color: #fff;
font-size: 12px;
line-height: 12px;
border-radius: 50% 50% 50% 0;
position: absolute;
right: 28px;
top: -8px;
}
.lt{
position: absolute;
right: 20px;
top: 0px;
}
</style>
</head>
<body>
<div class="cart">
<div class="text">我的购物车</div>
<span class="count">1</span>
<span class="lt">></span>
</div>
</body>
</html>