2010-11-30 111 views

回答

11

這應該工作:

<!DOCTYPE html> 
<html> 
    <head> 
     <style type="text/css"> 
      div { 
       position: absolute; 
       height: 80%; 
       width: 80%; 
       top: 10%; 
       left: 10%; 
       background-color: #FFCC00; 
      } 
     </style> 
    </head> 
    <body> 
     <div> 
      This should prove my point. 
     </div> 
    </body> 
</html> 
2

你可以試試:

CSS 
--- 
.container { 
    margin-top:10%; 
    margin-bottom:10%; 
    height:80%; 
} 

<div class="container"></div> 
+0

不,這是行不通的。它確實爲div的頂部添加了一個邊距,但高度仍然符合內容的要求(僅在Firefox,HTML5模式下)。 – tdammers 2010-11-30 20:09:25