Search code examples
csswordpresscss-shapeselementor

Make a rhombus image with border and padding


I would like to make an rhombus shaped image, with border and padding. I've managed to make the image in a rhombus shape, but haven't succeeded in making a border with padding around it.

I'm using elementor builder and looking for a solution that will not envolve js coding, only css. is there a way??

this is what I'm trying to achieve:1


Solution

  • Here is an idea with one element:

    .box {
      width: 150px;
      height: 150px;
      margin: 60px;
      /* this is your border*/
      outline: 2px solid;
      outline-offset: 15px;
      /**/
      overflow: hidden;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      transform: rotate(45deg);
    }
    
    .box::before {
      content: "";
      display: block;
      width: 141%;
      height: 141%;
      flex-shrink:0;
      background: center/cover;
      background-image: inherit;
      transform: rotate(-45deg);
    }
    
    body {
      background: yellow;
    }
    <div class="box" style="background-image:url(https://i.picsum.photos/id/1003/800/800.jpg)"></div>
    
    <div class="box" style="background-image:url(https://i.picsum.photos/id/1074/800/800.jpg)"></div>