2010-11-30 23 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

相关问题