Here's some HTML:
- <div class="container">
- <div class="row">
- <div class="col">
- <h1>Doggo</h1>
- <p><img src="doggo.jpg" alt="Doggo"></p>
- </div>
- </div>
- </div>
The doggo photo is large, 1,024px wide.
Open the page with this code.
Make the browser window smaller and larger. What happens to the image size?
Ray
Erm, nothing, the image stays the same size. I get scroll bars when I make the window smaller, because the image is too big to fit.
Right. Not great.
Let's add a class to the img
.
- <div class="container">
- <div class="row">
- <div class="col">
- <h1>Doggo</h1>
- <p><img class="img-fluid" src="doggo.jpg" alt="Doggo"></p>
- </div>
- </div>
- </div>
Try this version.
Make the browser window smaller and larger. What happens to the image size this time?
Ray
Better! The image resizes, with the browser window.
Right! That class on the img
tag, img-fluid
, makes images responsive.
That's the end of this lesson.
Adela
Wait, that's all there is to it? That one class?
Yep.
Up next
Responsiveness is something websites have to have these days. Another is accessibility. That's what the next lesson is about.