如何将弯曲的尾巴放在img后面

问题描述 投票:0回答:1

我试图让弯曲的尾巴位于图像后面,但无法实现这一点。我已经尝试过 z-index 但不起作用。

.bubble {
  position: relative;
  height: 150px;
  width: 255px;
  margin-right: 5px;
  border-radius: 25px 25px 0 25px;
  border: 2px solid #fff;
  background-image: url(https://ines-valdovinos.de/images/blog-bubble_teaser.jpg);
  background-size: contain;
}

.bubble::after {
  content: "";
  position: absolute;
  right: 0;
  background-color: transparent;
  bottom: -50px;
  height: 50px;
  z-index: 0;
  width: 25px;
  border-top-right-radius: 25px;
  box-shadow: 0 -25px 0 0 #fff;
}
<div class="bubble"></div>

我尝试过 z-index 0 和 -1,但不起作用。

css
1个回答
0
投票

这是您需要的解决方案。请应用此代码并进行测试。如果不起作用请告诉我。

.bubble {
  position: relative;
  height: 150px;
  width: 255px;
  margin-right: 5px;
  border-radius: 25px 25px 0 25px;
  border: 2px solid #fff;
  background-image: url(https://ines-valdovinos.de/images/blog-bubble_teaser.jpg);
  background-size: cover;
  background-position: center;
  z-index: 1;
}

.bubble::after {
  content: "";
    position: absolute;
    z-index: -1;
    bottom: -14px;
    right: -39px;
    width: 29px;
    height: 19px;
    background: #fff;
    -webkit-border-bottom-right-radius: 40px 50px;
    -moz-border-radius-bottomright: 40px 50px;
    border-bottom-left-radius: 66px 50px;
    -webkit-transform: translate(-10px, -2px);
    -moz-transform: translate(-10px, -2px);
    -ms-transform: translate(-10px, -2px);
    -o-transform: translate(-10px, -2px);
    transform: translate(-10px, -2px);
}

.bubble::before {
    content: "";
    position: absolute;
    z-index: -1;
    bottom: -13px;
    right: -14px;
    height: 16px;
    border-right: 30px solid #970d87;
    background: #970d87;
    -webkit-border-bottom-right-radius: 24px 41px;
    -moz-border-radius-bottomright: 80px 50px;
    border-bottom-left-radius: 80px 50px;
    -webkit-transform: translate(0, -2px);
    -moz-transform: translate(0, -2px);
    -ms-transform: translate(0, -2px);
    -o-transform: translate(0, -2px);
    transform: translate(0, -2px);
}
    <div class="bubble"></div>

© www.soinside.com 2019 - 2024. All rights reserved.