2014-09-05 4 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

+0

@Vucko HTML5에서는 유효하지만 걱정하지 마라. 주된 질문은 실제로하는 코드이다. –

+0

http://www.w3schools.com/css/css_boxmodel.asp – jbutler483

답변

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

관련 문제