How to create CSS images with oblique borders

What am i going

What I am trying to achieve

I have an image that should appear inside the polygon. The color pink is the image.

What i tried

Using the shapes of the SVG triangle (100% of the width) that lie above and below the image. Upper left track above and below left bottom.

It works fine, but it seems to have processing issues in many browsers where you see a random line around SVG. (see image below, there may be a separate question in itself)

enter image description here

I also tried using skewed / rotated elements above and below. But since the element is responsive, with a certain resolution, the skewed elements create spaces. (see image below)

enter image description here

What could i try

. . . , , , , .

- , , CSS.

+4
1

SVG

polygon, .
patterns, , .

URL .

.slanted {
  width: 100vw;
  height: auto;
}
.shape {
  fill: url(#img1);
}
<svg class="slanted" viewbox="-1 -1 102 102" preserveAspectRatio="none">
  <defs>
    <pattern id="img1" patternUnits="userSpaceOnUse" width="100" height="100">
      <image xlink:href="http://1.bp.blogspot.com/-uNrNW5JkyBU/UzA0xPGSvDI/AAAAAAAAEY0/I8TWWZK7hrw/s1600/LoremIpsum.png" x="0" y="0" width="150" height="100" />
    </pattern>
  </defs>
  <polygon class="shape" points="0,20 100,0 100,100, 0,80" />
</svg>
Hide result

CSS

3D- .
.
, 3D-.
transform: rotate() , .

.container {
  margin-top: 50px;
  perspective: 600px;
  width: 300px;
  height: 200px;
}
.shape {
  
  transform: rotateY(-45deg);
  width: 100%;
  height: 100%;
  background: url(https://s3-ap-southeast-1.amazonaws.com/expin/community/550e15686481272aad000023/M9a0doEXcgojevVuk38n.jpg);
}
<div class="container">
  <div class="shape"></div>
</div>
Hide result
+2

All Articles