HTML表格需要帮助。

huangapple go评论57阅读模式
英文:

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> NEWS:  </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.

&lt;style&gt;
  .outer-table {
    background: #000 url(background1.png);
    ...
  }
&lt;/style&gt;

&lt;body&gt;
  &lt;table class=&quot;outer-table&quot;&gt;
    ...
    &lt;table&gt;
      ...
    &lt;/table&gt;
  &lt;/table&gt;
&lt;/body&gt;

答案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>&nbsp;NEWS:&nbsp;&nbsp;</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);
}

个人而言,我更建议选择第一种选项 HTML表格需要帮助。

英文:

You have two possibilities here:
First one is just to set a class for each one of your tables.

&lt;head&gt;
&lt;title&gt;&lt;/title&gt;
&lt;style&gt;
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);
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body marginwidth=&quot;0&quot; marginheight=&quot;0&quot; topmargin=&quot;0&quot; bottommargin=&quot;0&quot; leftmargin=&quot;0&quot; rightmargin=&quot;0&quot; margin=&quot;0&quot; padding=&quot;0&quot; link=&quot;#1FOOFF&quot; vlink= &quot;#1FOOFF&quot; alink=&quot;#1FOOFF&quot; &gt;
&lt;center&gt;
&lt;table class=&quot;bg-1&quot; width=&quot;100%&quot; height=&quot;100%&quot; border=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; topmargin=&quot;0&quot; bottommargin=&quot;0&quot; leftmargin=&quot;0&quot; rightmargin=&quot;0&quot; margin=&quot;0&quot; padding=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; &gt;
&lt;tr&gt;
&lt;td width=&quot;100%&quot; height=&quot;100%&quot; valign=&quot;top&quot; &gt;
### this is where i want the style to end and use a new image ###
&lt;table  class=&quot;class=&quot;bg-2&quot;&quot; width=&quot;800&quot; height=&quot;10&quot; background:&quot;backgroun2.png&quot;&gt;
&lt;tr&gt;
&lt;td valign=&quot;center&quot; width=&quot;25 height=&quot;10&quot; bgcolor=&quot;red&quot; &gt;
&lt;font size=&quot;5&quot; face=&quot;Arial&quot;&gt;&lt;b&gt;&amp;nbsp;NEWS:&amp;nbsp;&amp;nbsp;&lt;/b&gt;
&lt;/td&gt;
&lt;td valign=&quot;top&quot; width=&quot;575&quot; height=&quot;10&quot; bgcolor=&quot;black&quot; &gt;
&lt;center&gt;
&lt;font size=&quot;5&quot; face=&quot;Arial&quot;&gt;
&lt;font color=&quot;#FFFFFF&quot;&gt;
&lt;marquee bgcolor=&quot;black&quot; behavior=&quot;scroll&quot; direction=&quot;left&quot; &gt;Now is the time to buy Gold and Silver.&lt;/marquee&gt;
&lt;/font&gt;
&lt;/font&gt;
&lt;/center&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/head&gt;

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 HTML表格需要帮助。

huangapple
  • 本文由 发表于 2023年6月5日 22:04:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/76407239.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定