Search code examples
htmlcssimageplaceholderwireframe

Image Placeholder with Percentages?


Any idea if there is a way to use a placeholder with percentages?
I know there is code that allows you to put pixel dimensions, but What about percentages instead? The code for the placeholder is img src="http://placehold.it/350x150". I am asking because I want to put together wireframes, but I also want it to fit to whatever screen is used. Thanks.


Solution

  • If you're using place hold it thats just the end file dimension you can use css to change the size to anything you want

    img{
     width:50%; /** Set to whatever you need **/
     height:auto; /** Retain image aspect ratio **/
    }
    

    Optional

    Add max-width,min-width / min-height, max-height for more control