当前位置: 代码迷 >> HTML/CSS >> css怎么让表格单元格里的div在所有元素之下
  详细解决方案

css怎么让表格单元格里的div在所有元素之下

热度:132   发布时间:2012-08-27 21:21:57.0
css如何让表格单元格里的div在所有元素之上
我一个表格的某个单元格里有个div,用作搜索结果的列表,我想让其在所有元素之上,我设置了z-index还是不行吗,请问高手如何实现这个效果呢?

------解决方案--------------------
要设置绝对定位position:absolute;z-index才有效果,然后用top、left 定位这个div的位置;
看一下我这个例子:
HTML code

<html>
<head>
</head>

<body>
<table width="185" border="1" cellspacing="0" cellpadding="0">
  <tr>
  <td style="width:185px; height:130px; position:relative;"></td>
  <td style="width:185px; height:130px; position:relative;">
  <div style="background:#ccc;filter:alpha(opacity=70);opacity:0.7;width:100px; height:150px; border:1px solid red; position:absolute; z-index:8; top:-9px; left:-20px;"></div>
 </td>
 <td style="width:185px; height:130px; position:relative;"></td>
  </tr>
</table>
</body>

</html> 
  相关解决方案