How to Mask Images with Dynamic Sizes to Shapes?


Tags: php,html,css

Problem :

I recently came across a problem when trying to find out how to mask dynamic-sized images to shapes like triangles. First I came along with a proportionate type approach where the size of the image would be passed to a variable in the style of the div along with the background image URL and tried to use the width and height proportionality to get the shape I wanted. I shortly realized that isn't possible with CSS. Therefore, I was wondering if there is any way to mask images with dynamic sizes to shapes other than using the mask property in CSS since it is not yet widely supported.



Solution :

Of course you can, the clip property let you use percentage values and it works since css2. Reference

Some examples: http://www.html5rocks.com/en/tutorials/masking/adobe/


    CSS Howto..

    How to use -webkit-appearance: searchfield-results-decoration?

    how to write a css that only can be visible on desktop in bootstrap

    How to have “onmouseover” highlight in css?

    How can I add a whitespace in between my element and psuedo element?

    how to make background fit on screen bootstrap3

    How to embed css in xml?

    Animation performance jQuery, css transition ? How can i have a better performance here?

    how to make smooth grayscale on hover using CSS

    How to add image at right bottom div using css

    Slideshow with specific Text on each Image

    How make something like Facebook Notifications?

    How JQuery can parse colors in text?

    How to stop this parent element from being affected on hover?

    How to position a SWIPER SLIDE in the centre of the page? [closed]

    How to implement a drag and swap effect in CSS and JS [closed]

    How to design multiple time clock wise rotation of a image in css

    How do I evenly space these links within my navbar div?

    nth-child's child is not shown

    How to Overlay a Transparent Navbar Over a Fullscreen Jumbotron

    How should I override hover style of a div in an anchor tag?

    How to make a shape which is made using css borders responsive?

    How to vertically align inline-block elements with height set and test with browser tools

    How to change scrollbar css at runtime with javascript?

    Sencha Touch 2: How to handle custom css files while production build?

    Progress Bar in jquery showing reverse animation

    How to customize unordered list items in HTML using CSS

    how to align buttons in css/html in one line horizontally?

    How to align css class using bootstrap

    How would you code this: The SO highlighted button outline effect [closed]

    How to style every odd p element after h2 element occured in css?