【发布时间】:2013-04-03 08:11:32
【问题描述】:
我不知道如何使用CSS 将图像置于前面。我已经尝试将 z-index 设置为 1000 并将位置设置为相对,但仍然失败。
这里是例子-
#header {
background: url(http://placehold.it/420x160) center top no-repeat;
}
#header-inner {
background: url(http://placekitten.com/150/200) right top no-repeat;
}
.logo-class {
height: 128px;
}
.content {
margin-left: auto;
margin-right: auto;
table-layout: fixed;
border-collapse: collapse;
}
.td-main {
text-align: center;
padding: 80px 10px 80px 10px;
border: 1px solid #A02422;
background: #ABABAB;
}
<body>
<div id="header">
<div id="header-inner">
<table class="content">
<col width="400px" />
<tr>
<td>
<table class="content">
<col width="400px" />
<tr>
<td>
<div class="logo-class"></div>
</td>
</tr>
<tr>
<td id="menu"></td>
</tr>
</table>
<table class="content">
<col width="120px" />
<col width="160px" />
<col width="120px" />
<tr>
<td class="td-main">text</td>
<td class="td-main">text</td>
<td class="td-main">text</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<!-- header-inner -->
</div>
<!-- header -->
</body>
【问题讨论】:
-
把什么放在前面?
也是 deprecated. -
把图片放在前面。
-
为什么要使用嵌套表格来制作菜单?
-
我在 IE8 中的菜单有问题,嵌套表格修复了它。
-
This video 非常有助于理解它的工作原理。