1

I have 4 div elements, one after the other. The 1st, 2nd, and 4th are working fine, but the 3rd div is not positioning properly. I am setting its position, but it's not following ...my code ..

.mid_table div is left aligned, but I want it to follow the coordinates given in CSS.

jsFiddle Example

CSS

#top_table {
    background-image: url(images/Round%20corner);
    background-repeat: no-repeat;
    background-position: center top;
    height: 25px;
}
#bottom_table {
    background-image: url(images/Round%20corner);
    background-repeat: no-repeat;
    background-position: center bottom;
    height: 25px;
}
#mid_table {
    background-color: #09F;
    left: 54px;
    width: 449px;
    height: 200px;
    position: relative;
}

HTML

<body>
<div id="logo" >
 <center>
  <h1><b> Portal</b></h1>
 </center>
</div>
<div id="top_table">
 <!-- empty -->
</div>
<div id="mid_table">
 Content for  id "mid_table" Goes Here
</div>
<div id="bottom_table">
 Content for  id "bottom_table" Goes Here
</div>
<div>
</body>
4

3 回答 3

0

你有没有尝试过

position: relative

? position: absolute 仅在对其他事物“绝对”时才有效。所以需要定位父母的祖先,例如 position: relative

于 2012-05-31T19:11:40.003 回答
0

与 position: relative 应该工作。(你的css中已经有了相对位置,所以我猜是编辑的人)

你在哪个浏览器上测试?如果它不适合您,则可能是浏览器问题。

你可以在这里查看。

jsfiddle

同样在您的 html 中,底部有一个未闭合的 div 标签。

于 2012-05-31T19:18:56.630 回答
0

我没有看到可能破坏第三个 div 显示的错误。只有 /body 标记之前未关闭的 div。你的浏览器是什么?坐标使用给定的属性相对位置。

于 2012-05-31T19:33:30.027 回答