background:url(您图片的路径) center center; 这样就可以了。原理是background-position定位,x轴和Y轴都定为 center
打字不易,如满意,望采纳。
奎聚楼之前回答过我的问题,就是图片的外面套个div,设置图片为背景,然后加上no-repeat center center;overflow:hidden就好了
你给图片外面加个div,然后在css中加上overflow:hide; width:500px; 这样的话图片如果大于500就隐藏了
text-align:center或者margin:0 auto;overflow:hidden,背景图:background:url(图片路径)no-repeat center center ;overflow:hidden
首先看图片高度多少, 然后用一个标签定义宽高度并把图片设置为这个标签的背景 坐标x,y为居中
例如:一张图片 1.jpg 高度 100px; 宽度不限
.div{
height:100px;
width:100%;
background:url("1.jpg") center center;
}