Home  >  Article  >  Web Front-end  >  How to achieve adaptive image size

How to achieve adaptive image size

一个新手
一个新手Original
2017-09-20 09:50:253530browse


Image size adaptation

We can easily implement image adaptation through bootstrap:

Pic

If you do not intend to reference bootstrap, simply css, we can check the definition of the img-responsive class in bootstrap:

.img-responsive {    
    display: inline-block;    
    height: auto;    
    max-width: 100%;}

In this way, we use pure CSS to complete the image adaptation;
Explain the code: display allows the image to be presented in a restrained form. And the width and height can be set;
Then use max-width to set the width, which can override the settings of the width attribute of the label by other classes; height makes the height of the picture adaptive, and can also be set in reverse, but this is generally the case More appear.

The above is the detailed content of How to achieve adaptive image size. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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