HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
Learn how to create an responsive image with CSS
Step 1) Add HTML:
<img src="nature.jpg" alt="Nature" class="responsive">
Step 2) Add CSS:
If you want the image to scale both up and down on responsiveness, set the CSS width
property to 100% and height
to auto:
If you want an image to scale down if it has to, but never scale up to be larger than its original size, use max-width: 100%
:
If you want to restrict a responsive image to a maximum size, use the max-width
property, with a
pixel value of your choice:
Go to our CSS Images Tutorial to learn more about how to style images.
Go to our CSS RWD Tutorial to learn more about responsive web design.