1 <!doctype html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>无标题文档</title> 6 <style> 7 *{ 8 margin:0; 9 padding:0; 10 list-style:none; 11 } 12 div{ 13 margin:0 auto; 14 height:10000px; 15 min-width:880px; 16 max-width:1100px; 17 background:#060; 18 clear:both; 19 } 20 ul{} 21 li{ 22 float:left; 23 display:inline; 24 width:198px; 25 height:198px; 26 border:1px solid #ccc; 27 margin:10px; 28 } 29 </style> 30 </head> 31 32 <body> 33 <div id="main"> 34 <ul> 35 <li>11111111111</li> 36 <li>2222222222</li> 37 <li>33333333333</li> 38 <li>4444444444</li> 39 <li>55555555555</li> 40 <li>666666666</li> 41 <li>77777777777</li> 42 <li>888888888888</li> 43 <li>999999999</li> 44 <li>00000000000</li> 45 <li></li> 46 <li></li> 47 <li></li> 48 <li></li> 49 <li></li> 50 <li></li> 51 <li></li> 52 <li></li> 53 <li></li> 54 <li></li> 55 <li></li> 56 <li></li> 57 <li></li> 58 <li></li> 59 <li></li> 60 </ul> 61 </div> 62 63 <script> 64 var winWidth; 65 window.onload=function(){ 66 if (window.innerWidth) 67 winWidth = window.innerWidth; 68 else if ((document.body) && (document.body.clientWidth)) 69 winWidth = document.body.clientWidth; 70 if(winWidth<=1100) 71 document.getElementById("main").style.width="880px"; 72 else if(winWidth>=1100) 73 document.getElementById("main").style.width="1100px"; 74 } 75 window.onresize=function(){ 76 if (window.innerWidth) 77 winWidth = window.innerWidth; 78 else if ((document.body) && (document.body.clientWidth)) 79 winWidth = document.body.clientWidth; 80 if(winWidth<=1100) 81 document.getElementById("main").style.width="880px"; 82 else if(winWidth>=1100) 83 document.getElementById("main").style.width="1100px"; 84 } 85 </script> 86 </body> 87 </html>