想了解免费建站的朋友,查看《免费建站教程》

超宽图片怎么居中显示 隐藏左右多余的部分

2020-03-31 1330 建站
/*外层DIV*/

div {position: relative;overflow:hidden;width: 显示宽度px;}

/*left=50%刚好在中间,margin-left=往前移动图片一半,这是图片就是居中了*/

img {border:none;width: 图片宽度px;position:absolute;top:0;left:50%;margin-left: -图片宽度一半px;}

or

.juzhong {position: relative;overflow:hidden;width:100%; height:auto;}
.juzhong img {border:none;width: 100%;position:relative;top:0;left:50%;margin-left: -50%;}


版权保护: 转载请保留链接: https://cgy.isi8.cn/jianzhan/119.html