-3

我想将 div 移动到底部,但如果我以百分比写入它不会移动,但以像素为单位它可以工作。

这是CSS:

 <style type="text/css">
  html
 {
 width:100%;
 height:100%;
  overflow-x:hidden;
  overflow-y:auto;
   }
  div#container
   {
position:relative;
width: 100%;
margin-top: 0px;
margin-left: auto;
margin-right: auto;
text-align:left; 
  }
  #g_image3
  {
  width: 100%;
  }
  body {text-align:center;margin:0}
   </style>`

这是html:

 <body bgColor="#000000">
 <div id="container">
  <div id="g_image3" style="position:absolute; overflow:hidden; left:0px; top:0px; z-   
 index:1"><img src="images/top_bg.jpg" alt="" title="" border=0 width="100%"   
 heigth="100%"></div>
  <div id="g_image4" style="position:absolute; overflow:hidden; left:0px; top: 10%;       
  width:265px; height:400px; z-index:1"><img src="images/content1.png" alt="" title=""   
  border=0 width=265 height=400></div>
 </div>
 </body>

这是一个带有页面图片的链接

我想将 g_image4 移动到底部,但如果我以百分比写它,它会一直
紧贴 g_image3。以像素为单位它可以工作,但我需要它以像素为单位的百分比。我哪里错了?我不明白为什么它不动....

4

1 回答 1

1

You have set a height: 100% on the html element but neglected to do so on the body and #container elements. This results in the body and #container elements having a height of 0, as there is no static or relative-positioned content in them to give them a height.

于 2013-06-07T19:02:49.960 回答