Code has been added to clipboard!

Making Sure You Have Your Bootstrap Image Responsive

Reading time 3 min
Published Jan 5, 2016
Updated Oct 2, 2019

We are all familiar with the experience of reading a plain text. It delivers the information we need, so you can say it gets the job done. Anyway, in a website or a web application, plain text could never be enough.

The reason is simple: the user wants more from the Internet that they do from a document. Apart from information, they also want design, interactivity, and a billion other things. That is why it is impossible to create a popular website without using images.

Using various classes Bootstrap 4 offers, we can display illustrations in different positions or shapes (say, a Bootstrap thumbnail or a circle). We can also use them to make our Bootstrap image responsive - that means it will be able to react to specific screen size and adapt its size.

Bootstrap Image: Main Tips

  • Bootstrap 4 offers image-oriented classes that allow you to position image elements or set the shape of the image container.
  • They can also come in handy when you need to make the scaling of your Bootstrap image responsive.
  • This tutorial will go over these classes.

Image Shape

In Bootstrap 4, you have classes that change how particular images are displayed. Let's have a closer look at each of them and get a better idea on how they function.

Circle

Using the .rounded-circle class you can make the image be displayed inside a circle.

Example
<img src="Example.jpg" class="rounded-circle" alt="Example">

Rounded Corners

Using the .rounded class, you can make the image be displayed with rounded corners:

Example
<img src="Example.jpg" class="rounded" alt="Example">
Udacity
Pros
  • Simplistic design (no unnecessary information)
  • High-quality courses (even the free ones)
  • Variety of features
Main Features
  • Nanodegree programs
  • Suitable for enterprises
  • Paid certificates of completion
Coursera
Pros
  • Professional service
  • Flexible timetables
  • A variety of features to choose from
Main Features
  • Professional certificates of completion
  • University-level courses
  • Multiple Online degree programs
Datacamp
Pros
  • Great user experience
  • Offers quality content
  • Very transparent with their pricing
Main Features
  • Free certificates of completion
  • Focused on data science skills
  • Flexible learning timetable

Bootstrap Thumbnail

Using .img-thumbnail class, you can make the image be displayed inside a bordered Bootstrap thumbnail:

Example
<img src="Example.jpg" class="img-thumbnail" alt="Example">

Aligning Bootstrap Images

There are also classes used to align Bootstrap images horizontally using the CSS float property. .float-left positions the image on the left side of an element, and .float-right positions it on the right:

Example
<img src="Example.jpg" class="float-left" alt="Example">
<img src="Example.jpg" class="float-right" alt="Example">

Making a Bootstrap Image Responsive

Using the .img-fluid class, you can make a Bootstrap image responsive (able to adjust to the screen size).

Look at the example provided below. The class we used here applied height: auto and max-width: 100% to the element it was used with:

Example
<img src="Example.jpg" class="img-fluid" alt="Example">

Bootstrap Image: Summary

  • Among the other new classes introduced in Bootstrap 4, a bunch of image-oriented ones was presented.
  • You can use them to shape and scale image containers, change the position of image elements and make your Bootstrap image responsive.

Latest Udacity Coupon Found:

Verified STAFF PICK

75% OFF COURSES

Udacity Black Friday Offer

The best time to save on Udacity courses is now - follow this coupon to access a 75% Udacity Black Friday discount & enjoy learning at a very low cost!

Expiration date: 08/03/2021
3176 People Used
Only 97 Left
Rating
5.0