利用vertical-align:middle实现在整个页面居中

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
   
 <html xmlns="http://www.w3.org/1999/xhtml"> 
 <head> 
     <title>404页面</title> 
 </head> 
 <body> 
     <div class="wall"> 
         <a href="index.html"><img class="img404" src="images/404.jpg" alt="404页面" /></a> 
     </div> 
 </body> 
 </html> 

<style type="text/css"> 
         body{ margin:0; background:#333; _height:100%;}  
         .wall{ width:100%; height:100%; position:absolute; left:0; top:0; text-align:center;}  
         .img404{ border:0;width:700px;}  
 </style> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    
  <html xmlns="http://www.w3.org/1999/xhtml"> 
  <head> 
      <title>404页面</title> 
      <style type="text/css"> 
          body{ margin:0; background:#333; _height:100%;}  
          .wall{ width:100%; height:100%; position:absolute; left:0; top:0; text-align:center; font-size:0;}  
          .img404{ border:0; width:700px; vertical-align:middle;}  
          .verticalAlign{ vertical-align:middle; display:inline-block; height:100%; width:1px; margin-left:-1px;}  
  </style> 
  </head> 
  <body> 
      <div class="wall"> 
         <span class="verticalAlign"></span> 
         <a href="index.html"><img class="img404" src="images/404.jpg" alt="404页面" /></a> 
      </div> 
  </body> 
  </html>

相关推荐