This is basically what i want to achieve --> https://jsfiddle.net/tak1pyt7/1/
.clip {
width: 500px;
height: 500px;
-webkit-clip-path: polygon(100% 0, 100% 81%, 82% 100%, 0 100%, 0 0);
clip-path: polygon(100% 0, 100% 81%, 82% 100%, 0 100%, 0 0);
}
body {
background-image: radial-gradient(circle, #3F9CBA 0%, #153346 100%);
height: 100%;
width: 100%;
}
<body>
<div class="clip">
<img src="http://lorempixel.com/600/600/" width="100%" height="100%" />
</div>
</body>
Although i have a solution but there are various issues with the code in the fiddle as follows :
- It doesn't work in IE or Edge as clip path isn't supported
- Clip path doesn't support css shapes in firefox and if you need to make it work in firefox then you need to supply inline svg
- Tried supplying inline svg as well but it has it's own set of issues that doesn't solve my requirement. I need the cut dimensions to remain the same irrespective of the height and width of the container. With inline svg that cuts the image right now, it's dimension changes with change in height and width i.e. the cut is responsive. I need static dimensions of the cut.
Other than above solution i searched a whole lot of solutions that might help me create div's with corners cut and the cut is transparent itself because i don't have a solid background at the back.
Other solutions explored
Using CSS3 Gradients sample
- Sample --> http://jsfiddle.net/spdawson/3Tc8S/light/
- Doesn't work when you have the content which occupies full height and width of the area such as the fiddle i provided at the beginning of the post.
Using CSS Borders
Sample --> http://jsfiddle.net/spdawson/HhZQe/light/
Doesn't work for me because The container on which the cut has to be made has to contain solid background color which is not the case for my design.
Using jQuery plugin (http://jquery.malsup.com/corner/)
Sample code --> http://jsfiddle.net/spdawson/nxnCD/light/
You need to have solid background color which isn't the case considering my requirement. I have a image as a background instead.
A Solution that WORKS but is very HACKY
Sample --> http://jsfiddle.net/26v7pfLb/
I am using this solution right now for containers that have fixed height and width but i have a page in my app where the containers have a static width but dynamic height. In that case the hack would be pretty difficult to implement and it seems very weird to use this solution personally.
I am trying to find something more elegant and clean to implement such a kind of solution in CSS
Any pointers would be helpful.