使 IMG 上的 CSS 三角形响应

Making CSS triangle on IMG responsive

想在图像上制作响应式三角形,但它没有调整大小,而且根本没有对齐。如何解决?

        .image {
            width: 100%;
        }

        .image:after {
            content: '';
            width: 0;
            height: 0;
            border-left: 20px solid transparent;
            border-right: 20px solid transparent;
            border-bottom: 20px solid #f5f5f5;
            position: absolute;
            left: 45%;
            top: 63%;
            transform: translatex(-50%);
            /** making it horizontally center **/
        }
<div class="image">
     <img src="img/frankie.png" class="img-fluid">
</div>

首先用 bootstrap position

position:relative 添加到父级(在你的情况下 .image

第二次使用bootstrap-4 classes作为w-100.image/img

Code in fiddle

.image:after {
  content: '';
  width: 0;
  height: 0;
  border-left: 20px solid transparent;
  border-right: 20px solid transparent;
  border-bottom: 20px solid #f5f5f5;
  position: absolute;
  left: 45%;
  top: 63%;
  transform: translatex(-50%);
}
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
  
<div class="image w-100 position-relative">
     <img src="https://i.stack.imgur.com/vdzwt.jpg" class="img-fluid  w-100">
</div>