2014-09-05 93 views
-6

这是我的代码,我想在CSS和HTML中创建框中的框如何改变盒子的位置?

但是当我做到了,我无法移动框,我需要从顶部的边缘,把框放在中心箱子或将它们移入主箱子,我该怎么办?

代码:

<html > 
    <head> 
     <style> 
      ui { 
       background-color:red; 
       padding:100px 100px; 
      } 

      div1{ 
       background-color:white; 
       padding:50px 50px; 
      } 

      div2{ 
       background-color:yellow; 
       padding:50px 50px; 
      } 
     </style> 
    </head> 

    <body> 
     <ui> 
      <div1>hello</div1> 
      <div2>bye</div2> 
     </ui> 
    </body> 

</html> 
+1

什么是''? – Vucko 2014-09-05 12:20:53

+0

@Vucko不用担心它在HTML5中有效,但主要问题是,代码实际上应该做什么! – 2014-09-05 12:21:25

+0

http://www.w3schools.com/css/css_boxmodel.asp – jbutler483 2014-09-05 12:22:46

回答

0
<!DOCTYPE html> 
<html> 
<head> 
<style> 
img { 
    position: absolute; 
    left: 0px; 
    top: 0px; 
    z-index: -1; 
} 
</style> 
</head> 
<body> 

<h1>This is a heading</h1> 
<img src="w3css.gif" width="100" height="140"> 
<p>Because the image has a z-index of -1, it will be placed behind the text.</p> 

</body> 
</html> 

产地:http://www.w3schools.com/css/tryit.asp?filename=trycss_zindex