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

标签 jquery html css

我在 clip-path 的帮助下在页面底部创建了 V 形导航栏。导航按钮的顶部必须保留圆形 div 元素。由于剪辑路径属性无法显示整个 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>

最佳答案

你能试试下面的代码吗——注意到我改变了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;
}

如果有帮助,请告诉我

关于jquery - 如何在使用 clip-path 属性的父元素上保留绝对子元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48689523/

相关文章:

jquery - 保存页面状态以供回访

javascript - 在 box-sizing :border-box is set in CSS? 时,JavaScript 中有没有一种方法可以直接获取元素的内容宽度

html - 如何并排对齐图像而不是彼此重叠?

javascript - 使用 JavaScript 更改多个元素样式

css - PhoneGap 对 FlexBox 模型的支持

css - 在 1-st 和 4-th 25% inline-block 之间需要空格

jquery - 异步 ajax 调用未按预期工作

javascript - 滚动模式时 bootstrap-datepicker 不滚动

jquery - Bootstrap selectpicker VueJS 指令

css - 链接有时在页面加载时可点击,有时不可点击