实现效果图:
原理:箭头主要通过clip-path来实现
直接上代码:
<!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 {
list-style: none;
margin: 0;
padding: 0;
}
.page {
background-color: #f2f3f5;
}
.pubSet {
background-color: #fff;
width: 1200px;
margin: 0 auto;
}
.head {
height: 60px;
background-image: url('/images/bg1.jpg');
border-bottom: 1px solid #e2e2e2;
}
.nav {
padding: 20px 20px 0;
display: flex;
align-items: center;
justify-content: center;
background-size: cover;
}
.nav li {
height: 40px;
line-height: 40px;
background-color: #fff;
color: #666;
font-size: 14px;
padding: 0 30px;
margin-left: -16px;
clip-path: polygon(0% 0%, calc(100% - 20px) 0%, 100% 50%, calc(100% - 20px) 100%, 0% 100%, 20px 50%);
}
.nav li:first-child {
clip-path: polygon(0% 0%, calc(100% - 20px) 0%, 100% 50%, calc(100% - 20px) 100%, 0% 100%, 0% 50%);
}
.nav li:last-child {
clip-path: polygon(0% 0%, 100% 0%, 100% 50%, 100% 100%, 0% 100%, 20px 50%);
}
.main {
min-height: 200px;
text-align: center;
padding-top: 50px;
}
</style>
</head>
<body>
<div class="page" id="app">
<div class="head pubSet">
<ul class="nav">
<li v-for="item in navList">{{item.name}}</li>
</ul>
</div>
<div class="main pubSet">这里是相关内容</div>
</div>
<script src="/js/vue.min.js"></script>
<script>
var vm = new Vue({
el: '#app',
data: {
navList: []
},
created: function () {
setTimeout(() => {
this.navList = [
{ name: '行政公益诉讼', url: '' },
{ name: '线索审查', url: '' },
{ name: '立案', url: '' },
{ name: '检察官办理案件', url: '' },
{ name: '诉前监察建议', url: '' },
{ name: '提起行政公益诉讼', url: '' },
{ name: '终结审查', url: '' }
]
}, 1000)
}
})
</script>
</body>
</html>