如何在使用clip-path属性的父元素上保留绝对子元素?

时间:2018-02-08 15:51:02

标签: jquery html css html5 css3

我在剪辑路径的帮助下在页面底部创建了V形导航栏。在导航按钮的顶部必须保持圆形div元素。由于clip-path属性无法显示整个div元素。我尝试在父类中使用overflow: visible属性。

我可以在此图片中看到我的问题:

enter image description here

.bottom-nav-section {
  padding: 20px;
  background-color: #fff;
  margin-bottom: 40px;
}

.bottom-nav {
  display: flex;
  align-items: center;
  width: 100%;
  height: 80px;
  background-color: #fff;
}

.clip1 {
  position: relative;
  float: left;
  width: 33.3%;
  margin: left:20px;
  height: 80px;
  background-color: #1c7aa2;
  outline: none;
  border: 0;
  padding: 20px;
  margin: 0 auto;
  text-align: center;
  -webkit-clip-path: polygon(0% 0%, 87% 0, 100% 50%, 86% 100%, 0% 100%);
  clip-path: polygon(0% 0%, 87% 0, 100% 50%, 86% 100%, 0% 100%);
}

.clip2 {
  position: relative;
  float: left;
  margin-left: -25px;
  margin-right: -25px;
  width: 33.3%;
  height: 80px;
  background-color: #1c7aa2;
  outline: none;
  border: 0;
  padding: 20px;
  text-align: center;
  -webkit-clip-path: polygon(86% 0, 100% 50%, 86% 100%, 0% 100%, 13% 48%, 0% 0%);
  clip-path: polygon(86% 0, 100% 50%, 86% 100%, 0% 100%, 13% 48%, 0% 0%);
}

.clip3 {
  position: relative;
  float: left;
  width: 33.3%;
  height: 80px;
  background-color: #1c7aa2;
  outline: none;
  border: 0;
  padding: 20px;
  margin: 0 auto;
  text-align: center;
  z-index: 1;
  overflow: visible !important;
  -webkit-clip-path: polygon(100% 0, 100% 50%, 100% 100%, 0% 100%, 13% 48%, 0% 0%);
  clip-path: polygon(100% 0, 100% 50%, 100% 100%, 0% 100%, 13% 48%, 0% 0%);
}

.clip-btn1 {
  position: absolute;
  display: block;
  width: 40px;
  height: 40px;
  left: 40px;
  top: -22px;
  text-align: center;
  padding: 2px;
  background-color: #1c7aa2;
  border-radius: 50%;
  border: 2px solid #fff;
  z-index: 999 !important;
}
<div class="row">
  <div class="col-xs-12 bottom-nav-section">
    <div class="logo-unit">
      <div class="bottom-nav">
        <button class="clip1"><h5>text1</h5>
          <div class="clip-btn1"><h5>1</h5></div>
        </button>
        <button class="clip2"><h5>text2</h5>
          <div class="clip-btn1"><h5>2</h5></div>
        </button>
        <button class="clip3"><h5>text3</h5>
          <div class="clip-btn1"><h5>3</h5></div>
        </button>
      </div>
    </div>
  </div>
</div>

1 个答案:

答案 0 :(得分:0)

您可以尝试下面的代码 - 注意到我更改了positionlefttop。你可以根据你想给我泡泡的地方改变左边和上边的位置

.clip-btn1 {
  position: relative;
  display: block;
  width: 40px;
  height: 40px;
  left: 11px;
  top: -66px;
  text-align: center;
  padding: 2px;
  background-color: #1c7aa2;
  border-radius: 50%;
  border: 2px solid #fff;
  z-index: 999 !important;
}

如果有帮助,请告诉我