表隐藏在img html后面

时间:2016-03-01 14:33:23

标签: html image html-table

我的html页面包含bg作为IMG SRC。

我希望TABLE在某个位置上的img。

实际上,如何让表格显示在图片的顶部?

如果我使用z-index我做错了什么?

注意:我在img结束的地方看到了表格的其余部分。

<!DOCTYPE html>
<html dir="rtl" lang="he">
<body>

<head>
   <TITLE>table on img bg</TITLE>
	<script src="include/jquery-2.2.0.min.js"></script>
	<meta charset="utf-8" />
	<style>
		html 
		{  
		
		} 
		
		h1 
		{
		font-family: arial;
		font-size: 350%;
		color: white;
		}
		
		#container
		{
		
		}
		
		#header
		{
		
		}
		#content
		{
		
		}
		#footer
		{
		
		}
		.tg  {border-collapse:collapse;border-spacing:0;border-color:#ebaa80;width:1918px;}
		.tg td{font-family:Arial, sans-serif;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:#ebaa80;color:#fff;}
		.tg th{font-family:Arial, sans-serif;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:#ebaa80;color:#ebaa80;}
		.tg .tg-o24q{font-weight:bold;text-align:center}
		.tg .tg-tdef{font-weight:bold}
	</style>
</head>
<div id="container">
	<img src="images/horizontal/bg.jpg" style="position: absolute; right: 0px; top: 0px;">
	<div id="header">
	<table class="tg">
	<tr>
	<th class="tg-o24q">Hours</th>
	<th class="tg-tdef">1</th>
	<th class="tg-tdef">2</th>
	<th class="tg-tdef">3</th>
	<th class="tg-tdef">4</th>
	<th class="tg-tdef">5</th>
	<th class="tg-tdef">6</th>
	<th class="tg-tdef">7</th>
	</tr>
	<%
		Response.Write "<TR>"
		Response.Write "<td class=tg-tdef>" & "a" & "</TD>"
		Response.Write "<td class=tg-tdef>" & "b" & "</TD>"
		Response.Write "<td class=tg-tdef>" & "c" & "</TD>"
		Response.Write "<td class=tg-tdef>" & "d" & "</TD>"
		Response.Write "<td class=tg-tdef>" & "e" & "</TD>"
		Response.Write "<td class=tg-tdef>" & "f" & "</TD>"
		Response.Write "<td class=tg-tdef>" & "g" & "</TD>"
		Response.Write "<td class=tg-tdef>" & "h" &  "</TD>"
		Response.Write "</TR>" & vbCrLf
		Response.Write "</table>" & vbCrLf
	%>
	<div id="header">
		<img src="images/horizontal/1.jpg" style="position: absolute; right: 0px; top: 0px;">
		<img src="images/horizontal/2.jpg" style="position: absolute; right: 0px; top: 210px;">
		<img src="images/horizontal/3.jpg" style="position: absolute; right: 0px; top: 440px;">
		<img src="images/horizontal/4.jpg" style="position: absolute; right: 0px; top: 610px;">
		<img src="images/horizontal/5.jpg" style="position: absolute; right: 0px; top: 1090px;">
		<img src="images/horizontal/6.jpg" style="position: absolute; right: 0px; top: 1320px;">
		<img src="images/horizontal/7.jpg" style="position: absolute; right: 0px; top: 1560px;">
	</div>
	
	<div id="content">		
		
	</div>
	
	<div id="footer">
		<img src="images/horizontal/8.gif" style="position: absolute; right: 50px; top: 1595px;">
		<img src="images/horizontal/9.gif" style="position: absolute; right: 565px; top: 1595px;">
	</div>
</div>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

更正

你的代码错了。 “head”标签应该是“html”标签的第一个子标签,因此是“body”标签的兄弟。

解决方案1 ​​

除了“z-index”属性外,添加“position:absolute”以创建重叠效果,如下所示:

img { position: absolute; left: 0px; top: 0px; z-index: -1; }

解决方案2

您可能想要尝试删除“img”标记,并将“body”标记替换为以下内容:

<body style="background-image:url(images/example-image-file.jpg)">

这会使整个图像成为页面的背景。

参考