0

我有一个要打开和关闭的信息表。但我需要表格出现在另一个 DIV 上方。

我可以在 info 表上使用 z-index 和 position:absolute 获得我想要的效果,但是没有 pos:absolute 是否可以达到相同的结果?也许与 pos:relative?我已经尝试过了,它似乎不起作用。

到目前为止,所有代码都非常简单,就是这样。

HTML

<div id="btnDiv"></div>
<table id="infoTable">
    <tr>
        <td>Objective Details</td>
        <td>Add task(btn) Image</td>
    </tr>
</table>
<div class="content">CONTENT</div>

CSS

#infoTable{
    display: none;
    position: relative;
    z-index: 10;

}

#btnDiv{
    width: 20px;
    height: 20px;
    background-color: green;
    float: right;
}


.content{
    width:100%;
    height:700px;
    background-color: blue;
}

jQuery

  $("#btnDiv").click(function showNewDiv(){
    $('#popIn').show();
    $("#popIn").css("z-index", 1);
  });

干杯!

4

3 回答 3

0

给表格一个负的上边距margin-top: -200px

于 2013-08-26T15:40:21.720 回答
0

修复了它,我只是把它们都放在另一个包含 div 中,并给了那个 div 位置:相对的。

于 2013-08-26T15:19:55.527 回答
0

对的,这是可能的。z-index属性适用于任何positionstatic.

因此,制作表格position: relative; z-index: 10和 div -position: relative; z-index: 5应该对您有所帮助。简单演示:http: //jsfiddle.net/uSCKJ/

于 2013-08-26T15:29:11.380 回答