实现效果如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!--<meta name="viewport" content=""/>-->
<title>导航练习</title>
<script scr="./练习一.js"></script>
<style>
body{
margin: 0px;
}
.box{
display: block;
background-color: #F0738A;
border-bottom: 3px outset #F0738A;
margin: 0px;
height: 50px;
margin: 0px 50px;
border-bottom-right-radius: 50px;
border-bottom-left-radius: 50px;
text-align: center;
padding-top: 20px;
}
.box2{
display: inline-block;
border-right: 2px solid #F41280;
color: #FFFFFF;
margin-right: 30px;
padding-right: 30px;
height: 30px;
line-height: 30px;
}
li>a{
display: inline-block;
color: #FFFFFF;
text-decoration: none;
}
</style>
</head>
<body>
<nav >
<ul class="box">
<li class="box2"><a href="">首页</a></li>
<li class="box2"><a href="">购物车</a></li>
<li class="box2"><a href="">浏览记录</a></li>
<li class="box2"><a href="">收藏夹</a></li>
</ul>
</nav>
</body>
</html>
在改动列表里面的元素时,剩下的能自动居中。