CSS 专题叙述

使用CSS mask 实现图片的斜线拼接

2018-07-11  本文已影响13人  科哚洛夫
效果图

改动里面的百分值 还有意想不到的效果哟

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>

  <style>
    .img-container {
      position: relative;
      width: 100%;
      height: 500px;
      border: 5px solid red;
    }

    .img-left {
      background: url('cc_memu.png');
      background-size: cover;
      width: 100%;
      height: 100%;
    }

    .img-right {
      position: absolute;
      left: 0;
      top: 0;
      background: url('p_memu.png');
      background-size: cover;
      -webkit-mask-image: -webkit-linear-gradient(left top, transparent 50%, white 50%);
      width: 100%;
      height: 100%;
    }
  </style>
</head>

<body>
  <div class="img-container">
    <div class="img-left"></div>
    <div class="img-right"></div>
  </div>
</body>

</html>


上一篇下一篇

猜你喜欢

热点阅读