英文:
HTML TABLE help needed
问题
这有点按照我的要求工作。第一个表格的背景图像效果很好,并且它也很好地调整了图像大小。
但我遇到的问题是,当我尝试在第一个表格内创建另一个表格时,它仍然使用第一个表格的背景,尽管我告诉它使用新的背景图像。
那么,我应该如何做到在完成第一个表格后结束样式,而不在第一个表格内的第二个表格中使用它。
提前感谢您的任何帮助。
英文:
This kinda works the way i want it. AS in the first table has the background image working just fine and its resizing the image just fine.
But the prob im having is now when i try to make another table inside the first table its still using the first background from the first table even though im telling it to use a new background image.
So how do i do this so the style ends after it does the first table, and not get used in the 2 table that is inside the first table.
Thanks ahead of time for any help.
<html>
<head>
<title></title>
<style>
table{
background: #000 url(background1.png);
height: 100%;
border: none;
margin: 0px;
background-size: 100%;
background-repeat: no-repeat;
background-position: center;
}
</style>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" margin="0" padding="0" link="#1FOOFF" vlink= "#1FOOFF" alink="#1FOOFF" >
<center><table width="100%" height="100%" border="0" marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" margin="0" padding="0" cellspacing="0" cellpadding="0" >
<tr>
<td width="100%" height="100%" valign="top" >
### this is where i want the style to end and use a new image ###
<table width="800" height="10" background:"backgroun2.png">
<tr>
<td valign="center" width="25 height="10" bgcolor="red" >
<font size="5" face="Arial"><b>&nbsp;NEWS:&nbsp;&nbsp;</b>
</td><td valign="top" width="575" height="10" bgcolor="black" >
<center><font size="5" face="Arial"><font color="#FFFFFF"><marquee bgcolor="black" behavior="scroll" direction="left" >Now is the time to buy Gold and Silver.</marquee></font></font></center>
</td></tr></table>
</td></tr></table>
答案1
得分: 3
尝试使用CSS类而不是按类型引用表格。这样,您可以为外部表格和内部表格分别设置不同的样式。请查看这里以获取有关CSS类的信息。
https://developer.mozilla.org/en-US/docs/Web/CSS/Class_selectors
例如:
<style>
.outer-table {
background: #000 url(background1.png);
...
}
</style>
<body>
<table class="outer-table">
...
<table>
...
</table>
</table>
</body>
英文:
Try using CSS classes instead of referencing the table by type. That way you can give your outer table different styles to your inner table. See here for information about CSS classes.
https://developer.mozilla.org/en-US/docs/Web/CSS/Class_selectors
e.g.
<style>
.outer-table {
background: #000 url(background1.png);
...
}
</style>
<body>
<table class="outer-table">
...
<table>
...
</table>
</table>
</body>
答案2
得分: 0
你有两种选择:
第一种是为每个表格设置一个类。
<head>
<title></title>
<style>
table{
background: #000 url(background1.png);
height: 100%;
border: none;
margin: 0px;
background-size: 100%;
background-repeat: no-repeat;
background-position: center;
}
.bg-1{
background: #000 url(background1.png);
}
.bg-2{
background: #000 url(background2.png);
}
</style>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" margin="0" padding="0" link="#1FOOFF" vlink="#1FOOFF" alink="#1FOOFF">
<center>
<table class="bg-1" width="100%" height="100%" border="0" marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" margin="0" padding="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" height="100%" valign="top">
### 这是我想要样式结束并使用新图像的地方 ###
<table class="bg-2" width="800" height="10" background="background2.png">
<tr>
<td valign="center" width="25 height="10" bgcolor="red">
<font size="5" face="Arial"><b> NEWS: </b></font>
</td>
<td valign="top" width="575" height="10" bgcolor="black">
<center>
<font size="5" face="Arial">
<font color="#FFFFFF">
<marquee bgcolor="black" behavior="scroll" direction="left">现在是买黄金和白银的时候。</marquee>
</font>
</font>
</center>
</td>
</tr>
</table>
</td>
</tr>
</table>
</center>
</body>
或者,你可以将它添加到CSS中,使第二个背景仅适用于表格内部的表格。
table{
background: #000 url(background1.png);
height: 100%;
border: none;
margin: 0px;
background-size: 100%;
background-repeat: no-repeat;
background-position: center;
}
table table{
background: #000 url(background2.png);
}
个人而言,我更建议选择第一种选项
英文:
You have two possibilities here:
First one is just to set a class for each one of your tables.
<head>
<title></title>
<style>
table{
background: #000 url(background1.png);
height: 100%;
border: none;
margin: 0px;
background-size: 100%;
background-repeat: no-repeat;
background-position: center;
}
.bg-1{
background: #000 url(background1.png);
}
.bg-2{
background: #000 url(background2.png);
}
</style>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" margin="0" padding="0" link="#1FOOFF" vlink= "#1FOOFF" alink="#1FOOFF" >
<center>
<table class="bg-1" width="100%" height="100%" border="0" marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" margin="0" padding="0" cellspacing="0" cellpadding="0" >
<tr>
<td width="100%" height="100%" valign="top" >
### this is where i want the style to end and use a new image ###
<table class="class="bg-2"" width="800" height="10" background:"backgroun2.png">
<tr>
<td valign="center" width="25 height="10" bgcolor="red" >
<font size="5" face="Arial"><b>&nbsp;NEWS:&nbsp;&nbsp;</b>
</td>
<td valign="top" width="575" height="10" bgcolor="black" >
<center>
<font size="5" face="Arial">
<font color="#FFFFFF">
<marquee bgcolor="black" behavior="scroll" direction="left" >Now is the time to buy Gold and Silver.</marquee>
</font>
</font>
</center>
</td>
</tr>
</table>
</td>
</tr>
</table>
</head>
Or you can just add it in CSS so your second bg apply only to the tables insides a table
table{
background: #000 url(background1.png);
height: 100%;
border: none;
margin: 0px;
background-size: 100%;
background-repeat: no-repeat;
background-position: center;
}
table table{
background: #000 url(background2.png);
}
Personnally i would rather recommand the first option
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论