CSS IMG 居中自适应收集

xiaoxiao2021-02-28  6

1.section方案

class

.centerImg{ border:solid 1px #ccc; background-color:red; background-image:url(xxx.jpg); background-origin:content; background-position:50% 50%; background-size:contain; /*保持图像本身的宽高比例,将图片缩放到宽度或高度正好适应定义背景的区域*/ background-repeat:no-repeat; }

use

<section class="centerImg" style="width:400px;height:200px;"></section>
转载请注明原文地址: https://www.6miu.com/read-1150364.html

最新回复(0)