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

Applying Background Image to shape

I’m working on a small web project and I’m currently trying to show a background image as a shaped object. Is it possible to display a regular square background image as a transformed shape like in the image below?

I tried to rotate a div, but then the image itself would be rotated as well.

What are other options that could help me archive an effect like in the image using html/css or js?

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

Thank you very much in advance.

enter image description here

>Solution :

You can use clip-path in css to build custom shapes. Use this website from Benett Feely as a cheatsheet.

article {
  width: 30vw;
  height: 100vh;
  margin-left: auto;
  background: url(https://picsum.photos/200) center/cover no-repeat;
  clip-path: polygon(24% 0, 100% 0, 100% 100%, 0 100%);
}
<article></article>
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