css控制div中的超宽图片居中并隐藏超出当前分辨率宽度的部分

2025-02-26 23:08:12
推荐回答(5个)
回答1:

background:url(您图片的路径) center center; 这样就可以了。原理是background-position定位,x轴和Y轴都定为 center
打字不易,如满意,望采纳。

回答2:

奎聚楼之前回答过我的问题,就是图片的外面套个div,设置图片为背景,然后加上no-repeat center center;overflow:hidden就好了

回答3:

你给图片外面加个div,然后在css中加上overflow:hide; width:500px; 这样的话图片如果大于500就隐藏了

回答4:

text-align:center或者margin:0 auto;overflow:hidden,背景图:background:url(图片路径)no-repeat center center ;overflow:hidden

回答5:

首先看图片高度多少, 然后用一个标签定义宽高度并把图片设置为这个标签的背景 坐标x,y为居中

例如:一张图片 1.jpg 高度 100px; 宽度不限

.div{
    height:100px;
    width:100%;
    background:url("1.jpg") center center;
}

相关问答