Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to show image as attached shape using html css

enter image description here

I tried to do it using linear-gradient but unable to achieve border radius on top left corner.

.img-container {
    background-image: url('https://loremflickr.com/680/520/car,forest');
    background-repeat: no-repeat;
    background-size: cover;
    border-radius: 0px 42px 42px 4px;
    position: relative;
    width: 600px;
    height: 320px;
    background-position: 100%;
}

.img-container::before {
    content: '';
    position: absolute;
    left: 0;
    top: -4px;
    width: 182px;
    height: calc(100% + 2px);
    background: linear-gradient(to top left, transparent 50%, white 50.1%)
      bottom left / 182px no-repeat transparent;
}
<div class="img-container"></div>

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Skew transformation can help here:

.img-container {
  border-radius: 10px;
  height: 250px;
  width: 400px;
  overflow: hidden;
  transform-origin: bottom;
  transform: skewX(-20deg);
}

img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0px 42px 42px 4px;
  transform-origin: bottom;
  transform: skewX(20deg); /* the opposite value here */
}
<div class="img-container">
  <img src="https://loremflickr.com/680/520/car,forest">
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading