CSS+HTML<箭头导航栏效果>

效果图:

image.png

通过css中的clip-path属性就能简单实现这种效果

代码如下:

html:

 <div class="box">
      <span class="tab">1</span>
      <span class="tab">2</span>
      <span class="tab">3</span>
    </div>

css:

.tab {
  margin-left: -0.5rem;
  cursor: pointer;
  transition: 0.5s;
  display: inline-block;
  width: 150px;
  height: 40px;
  line-height: 40px;
  background: #ccc;
  color: white;
  font-weight: bold;
  clip-path: polygon(0% 0%, 95% 0%, 100% 50%, 95% 100%, 0% 100%, 5% 50%);
}
.tab:hover {
  background: royalblue;
}
.tab:first-child {
  clip-path: polygon(0% 0%, 95% 0%, 100% 50%, 95% 100%, 0% 100%, 0% 50%);
}
.tab:last-child {
  clip-path: polygon(0% 0%, 100% 0%, 100% 50%, 100% 100%, 0% 100%, 5% 50%);
}
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容