Making an image responsive using css

the following css will make an image display 100% its size and keep its aspect ratio if the screen size or element size gets smaller than the containing image. you should be able to drag the edge of the image to resize and see how it responds.

HTML

<div class='resizeable'><img class='responsive' src='https://kruxor.com/images/inspiron-13-7370-2.jpg'></div>

CSS

img.responsive {
	max-width: 100%;
	display: block;
	height: auto;
}
.resizeable {
	height: 400px;
  	width: 300px;
	resize: horizontal;
    overflow: auto;
    border: 1px solid #000;
}

Demo

Other Items in css
Page Views

This page has been viewed 67 times.

Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.

❤👩‍💻🕹