Home > Article > Web Front-end > How to introduce images into bootstrap
There are two common ways to introduce images using Bootstrap: use the <img> element to specify the src attribute; use the img-fluid class to adapt the image to the width of the container.
How to use Bootstrap to introduce images
Bootstrap provides a variety of ways to introduce images. Here are the two most popular ones: Commonly used methods:
Use img
element
This is the most direct method, just use <img>
element, and specify the src
attribute to point to the path of the image. For example:
<code><img src="image.jpg" alt="图片说明"></code>
Use the img-fluid
class
Bootstrap provides the img-fluid
class, which can make images automatically Fits to the width of the container. To use this method, add the img-fluid
class on the <img>
element. For example:
<code><img class="img-fluid" src="image.jpg" alt="图片说明"></code>
Other options
In addition to the above two methods, Bootstrap also provides other options to control the appearance of the image:
img-thumbnail
Class: Creates a thumbnail with borders and rounded corners. img-rounded
Class: Create an image with rounded corners. img-circle
Class: Create a circular image. figure
Elements: Add a title and description to the image. Tips
img-fluid
class to ensure that images can be displayed correctly on different devices. alt
attribute to provide an alternative text for the image to use when the image cannot be displayed. The above is the detailed content of How to introduce images into bootstrap. For more information, please follow other related articles on the PHP Chinese website!