css - 一种让超大banner图片不拉伸、全屏宽、居中显示的方法

独自空忆成欢 提交于 2019-12-08 01:14:04
  1. <html>  
  2. <head>  
  3.     <title>Title</title>  
  4.     <style>  
  5.         .bannerbox {  
  6.             width:100%;  
  7.             position:relative;  
  8.             overflow:hidden;  
  9.             height:200px;  
  10.         }  
  11.         .banner {  
  12.             width:3000px;  
  13.             position:absolute;  
  14.             left:50%;  
  15.             margin-left:-1500px;  
  16.         }  
  17.     </style>  
  18. </head>  
  19. <body>  
  20.     <div class="bannerbox">  
  21.         <div class="banner">  
  22.             <img src="t1.jpg">  
  23.         </div>  
  24.     </div>   
  25. </body>  
  26. </html>  
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!