Join Jen Kramer for an in-depth discussion in this video Incorporating images, part of Learning Bootstrap 2.
So this page is looking better than when we started, but it's still lacking in a lot of color and a lot of interest, and one of the things that we could do to make page more interesting and break up the text a little bit, of course, would be to add a few images. But in addition to that, I'd like to tell you about some great image treatments that ship with Bootstrap that are really fun. You can take a square image and apply a style to that. We will make it appear round on your web page. There is a treatment that will give you rounded corners on the images, and there is also something called the Polaroid treatment, it will put a gray line around your image, as well as a white border.
So, there are some images inside your exercise files, so make sure you go ahead and copy those into your Bootstrap site, and we're going to hop in Dreamweaver here, we'll go ahead and add those images. So the first place I'm going to add an image is right here after Art in Full Color. In fact, right inside this paragraph here, describing Art in Full Color, I'm going to go ahead and add my image tag, so image source equals, and as always we can browse for that. I'm going to pick the flower here from your images folder and say OK.
These are just sort of decorative pictures, so I'm just going to give them an empty alt tag. It's not really important that people with disabilities are able to see these pictures, you can certainly put in a description for them if you wish. Then I'm going to scroll on down the page here, and I'm going to insert another picture. Let's scroll on down to right here, Tuesday, March 6, just before the strong tag here, between the paragraph, I want to go ahead and insert another image file.
And once again, we can browse for the image and here I am going to put in the picture of this artist. And once again, I'm just going to leave a blank alt tag, we should always include that alt tag, though. And then finally, I'm going to scroll in down the page here to just before Exhibits A & B, so this is around line 60. I'm going to go ahead and add an image tag right here inside of this paragraph, and this particular image that I'm going to put in is the picture of the road, and once again, a blank alt tag.
Okay, so I've just added three images to my document, if I go ahead and say File > Save, and I pop in to Firefox and I take a look at my page and I Refresh, you'll see that I have these pictures, so here's my picture of the flower, down here is a picture my artist, and down here at the very bottom is the picture of the road, and it looks a little bit chunky and blocky, so I'm going to add some additional styles to these to give them those treatments that I discussed. Let's switch back to Dreamweaver and scroll back on up the page here to the flower image, and I'm going to add some classes do this.
So the big class I'm going to add to this is image, img-circle, which will give us a treatment of a circular image. So if you just do that much and save your page and take a look at it in Firefox, you'll see that, lo and behold, your squared-off image has now become a circle, and it looks great. I am now also going to float this on over to the right side of the page. I don't think it really works over here on the left side. So, inside of Dreamweaver, I'm going to add a second class, it's our old friend pull-right, which will float the image over to the right side of the page.
So we'll go ahead and save that again, take a look at it in Firefox, and you'll see we have a nice round image over here pushed to the right side of the page, looks a lot better. So that's one of the treatments that's available to you in Bootstrap image, img-circle will give you the circular images. Now if we go back to Dreamweaver again, and we scroll on down the page, back to our second image here with the image of the artist, I'm going to go ahead and add another class, and I'm going to give this a class of img-rounded, which will give it rounded corners, and in addition to that I'm also going to do the same thing again, I'm going to do a pull-right to make it float to the right side of the page.
Save this again, and if you refresh it here inside of Firefox, you'll see that we have our image of our artist over here floating out to the right side of the page. You'll see that the image corners on this are also rounded, which is a nice treatment. Last, we're going to give this road picture down here a treatment, so scroll on down in your document to the road picture, and for this one we'll go ahead and add a class for it, and the class is img-polaroid, and once again, I'll add a pull-right to that particular class and go ahead and Save that, and we'll Refresh that inside of Firefox, and you'll see that we now have our image of the road over here on the right side of the page.
You see that we have a nice gray border going around that with some white in between. If I had a different color background, that white in between the light gray line and the picture would stay white, which explains the name Polaroid. So there we go, three image treatments here inside of Bootstrap. You can make use of these very, very simply with a single class, the Polaroid treatment, the Rounded corner treatment, and of course, the Circle treatment up here on the top.
- Understanding the difference between default and fluid grids
- Nesting with fluid grids
- Creating a thumbnail gallery
- Adding block quotes and lists of text
- Incorporating images and icons
- Adding breadcrumb navigation and pagination
- Using tabs and pills navigation
- Adding dropdown menus to the nav bar, tabs, and pill