Home > Web Front-end > Bootstrap Tutorial > How to make images adapt to the screen in bootstrap

How to make images adapt to the screen in bootstrap

藏色散人
Release: 2019-07-20 11:33:07
Original
5596 people have browsed it

How to make images adapt to the screen in bootstrap

How does bootstrap make images adapt to the screen

The correct setting for bootstrap responsive images is to add them above img Just go to two categories.

<img src="..." class="img-responsive center-block" >
Copy after login

If it is in the content page, just use js to add attributes to each img.

$(window).load(function(){
 
    $(".panel-body img").addClass("img-responsive center-block");
 
})
Copy after login

In Bootstrap version 3, images can support responsive layout by adding the .img-responsive class to the image. The essence is to set the max-width: 100%;, height: auto; and display: block; attributes for the image, so that the image can be better scaled in its parent element.

If you need to center the image using the .img-responsive class horizontally, please use the .center-block class instead of .text-center.

SVG Images and IE 8-10

In Internet Explorer 8-10, SVG images set to .img-responsive appear unevenly sized. To solve this problem, add width: 100% \9; where the problem occurs. Bootstrap does not automatically set this property for all image elements, as this would cause other image formats to mess up.

Related recommendations: "bootstrap tutorial"

The above is the detailed content of How to make images adapt to the screen in bootstrap. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template