怎样让img显示原始比例!DOCTYPE htmlhtml lang=enhead meta charset=UTF-8 meta name=author content=Xue Huanqun titleTitletitle style type=textcss img position absolute; left 0px; top 0px;
可以在CSS中使用max-width属性来让img显示原始比例,如下所示:
img { position: absolute; left: 0px; top: 0px; z-index: -1; max-width: 100%; height: auto; }
这样,当img的宽度超过其父元素的宽度时,它会自动缩小并保持原始比例。
原文地址: https://www.cveoy.top/t/topic/d6Rh 著作权归作者所有。请勿转载和采集!