Home > Article > Web Front-end > How to scale images in in html_html/css_WEB-ITnose
I put a background image in . When the image is too large, part of it will be displayed. If it is too small, it will be automatically centered. Please tell me how to set it up so that all images will be displayed regardless of whether they are too large or too small. Please give me some advice.
Baidu can display an image vertically, horizontally and centered
Give the image a specified width.
1. Set a fixed width and height for the image
2. Use js to control the size of the image. If it is smaller than the setting, it will be the original size. If it is larger, it will be adjusted proportionally by js
You are here When writing in span, you need to write the width and height of span display: block; overflow: hidden;
Use jquery. If the width is greater than the maximum value, set the image width to the maximum width value, and then use jquery to implement it. Height = actual height/(actual width/maximum width)