之前写过一个《大图(宽图)在任意宽度浏览器内显示原尺寸、并居中、无导航条CSS》
本文的分享来自于我今天的一个zblog模板仿站单子,比之前分享的方法代码要跟精简,所以还是建议之前之前的特效代码(兼容性本文的更好)
,所以今天这个也必须分享出来:
一样的功能,不一样的代码,都可以使长图在任意宽度浏览器缩放中原尺寸居中,超出图片部分使用背景色!
<style> *{margin:0;padding:0;list-style-type:none;} a,img{border:0;text-decoration:none;} /* mainbanner */ .mainbanner{height:184px;overflow:hidden; position:relative;} .mainbanner_window{left:50%;width:2000px;height:180px;overflow:hidden;margin-left:-1000px;position:absolute;} .mainbanner_window ul{width:999999px;position:relative;} .mainbanner_window li{background:#ee0501;width:2000px;text-align:center;font-size:0px;float:left;display:inline;} </style> <div class="mainbanner"> <div class="mainbanner_window"> <ul id="slideContainer"> <li><a target="_blank"><img src="http://localhost/zb_users/theme/ydzyw/style/images/minilogo.jpg" width="1440" height="180" /></a></li> </ul> </div> </div>
这种居中效果在很多网站上都有,特别是幻灯片区,头部背景区都可能遇到,所以分享出来。
Copyright © 广州京杭网络科技有限公司 2005-2025 版权所有 粤ICP备16019765号
广州京杭网络科技有限公司 版权所有