Using css to realize the css of WeChat Mini Programs image component mode = aspectFill, which allows the picture to be scaled in proportion and cut automatically.

WeChat Mini Programs image

keep the aspect ratio to zoom the picture, only ensure that the short edge of the picture can be fully displayed. In other words, the picture is usually complete only in the horizontal or vertical direction, and the other direction will be intercepted.

html structure

<div class="pic-box">
    <img :src="item.picture" />
</div>

due to the different length of the picture, the proportion is not fixed.

here is a real column implemented with a background image.


css itself has a relatively niche attribute object-fit,

you only need to set object-fit: cover to the img tag to Ok, which has the same effect as background-size:cover;.

if it is on a mobile phone, you can rest assured to use it. If you use it on pc, you need to consider compatibility. It is not compatible with IE

.

for more information, please refer to the document

.

MDN object-fit

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3aea7-2c25d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3aea7-2c25d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?