In this example you will learn, how to create a responsive image with CSS. Following is the code to create a responsive image with CSS:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> img { width: 100%; max-width: 1000px; } </style> </head> <body> <h1>Responsive Images Example</h1> <h2>Resize the window to see responsive image scale up and down</h2> <img src="https://images.pexels.com/photos/34950/pexels-photo.jpg"> </body> </html> |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.