我继承了一些网页更新的责任,并且必须在现有设计的参数范围内工作,但使用的编码是所有表格,每个表格单元格中都有很多格式。我只是想解决它就头疼。我想通过使用样式来简化,并且需要有几种不同的样式。具体来说,表格标题都是粗体、居中和一种字体大小,因此它将获得一种样式的行。第一列需要加粗并居中,第五列居中(但常规字体粗细)。所有其他列都是左对齐和常规权重。这些行在白色和彩色之间交替。
所以我的问题是我可以以两种样式设置行以更改颜色,然后我将如何设置需要加粗和/或居中的 2 列的样式,或者我是否需要设置每个单元格的样式以使其工作?
<tr style="height: 27.75pt">
<td style="padding-right: 5.4pt; padding-left: 5.4pt; background: #d2eaf1; padding-bottom: 0in; border-left: #78c0d4 1pt solid; width: 41.4pt; border-top-color: #f0f0f0; padding-top: 0in; border-bottom: #78c0d4 1pt solid; height: 27.75pt; border-right-color: #f0f0f0" valign="top" width="55">
<p align="center" style="margin: 0in 0in 0pt; line-height: normal; text-align: center">
<strong><span style="font-size: 10pt; color: black; font-family: 'Tahoma','sans-serif'">2</span></strong></p>
</td>
<td style="padding-right: 5.4pt; padding-left: 5.4pt; border-left-color: #f0f0f0; background: #d2eaf1; padding-bottom: 0in; width: 137.8pt; border-top-color: #f0f0f0; padding-top: 0in; border-bottom: #78c0d4 1pt solid; height: 27.75pt; border-right-color: #f0f0f0" valign="top" width="184">
<p style="margin: 0in 0in 0pt; line-height: normal">
<span style="font-size: 10pt; font-family: 'Tahoma','sans-serif'">Grace Episcopal Church</span></p>
</td>
<td style="padding-right: 5.4pt; padding-left: 5.4pt; border-left-color: #f0f0f0; background: #d2eaf1; padding-bottom: 0in; width: 72.45pt; border-top-color: #f0f0f0; padding-top: 0in; border-bottom: #78c0d4 1pt solid; height: 27.75pt; border-right-color: #f0f0f0" valign="top" width="97">
<p style="margin: 0in 0in 0pt; line-height: normal">
<span style="font-size: 10pt; font-family: 'Tahoma','sans-serif'">Nyack</span></p>
</td>
<td style="padding-right: 5.4pt; padding-left: 5.4pt; border-left-color: #f0f0f0; background: #d2eaf1; padding-bottom: 0in; width: 96.85pt; border-top-color: #f0f0f0; padding-top: 0in; border-bottom: #78c0d4 1pt solid; height: 27.75pt; border-right-color: #f0f0f0" valign="top" width="129">
<p style="margin: 0in 0in 0pt; line-height: normal">
<span style="font-size: 10pt; font-family: 'Tahoma','sans-serif'">John Smith</span></p>
<p style="margin: 0in 0in 0pt; line-height: normal">
<span style="font-size: 10pt; font-family: 'Tahoma','sans-serif'">Tom Jones </span></p>
</td>
<td style="padding-right: 5.4pt; padding-left: 5.4pt; border-left-color: #f0f0f0; background: #d2eaf1; padding-bottom: 0in; width: 63pt; border-top-color: #f0f0f0; padding-top: 0in; border-bottom: #78c0d4 1pt solid; height: 27.75pt; border-right-color: #f0f0f0" valign="top" width="84">
<p align="center" style="margin: 0in 0in 0pt; line-height: normal; text-align: center">
<span style="font-size: 10pt; font-family: 'Tahoma','sans-serif'">222-1234</span></p>
<p align="center" style="margin: 0in 0in 0pt; line-height: normal; text-align: center">
<span style="font-size: 10pt; font-family: 'Tahoma','sans-serif'">333-6789</span></p>
</td>
<td style="border-right: #78c0d4 1pt solid; padding-right: 5.4pt; padding-left: 5.4pt; border-left-color: #f0f0f0; background: #d2eaf1; padding-bottom: 0in; width: 147.4pt; border-top-color: #f0f0f0; padding-top: 0in; border-bottom: #78c0d4 1pt solid; height: 27.75pt" valign="top" width="197">
<p style="margin: 0in 0in 0pt; line-height: normal">
<a href="mailto:johnsmith@optonline.net"><span style="font-size: 10pt; font-family: 'Tahoma','sans-serif'">johnsmith@optonline.net</span></a></p>
<p style="margin: 0in 0in 0pt; line-height: normal">
<a href="mailto:tomjones@att.net"><u><span style="font-size: 10pt; font-family: 'Tahoma','sans-serif'">tomjones@att.net </span></u></a></p>
</td>
</tr>
我已经用内部样式表清理了大部分代码,但还有两个问题。每列的宽度不会使用每个列类中的宽度样式更改。此外,当我将字体大小从 11pt 更改为 12 pt 时,它会将文本包裹在两列中,从而偏离了表格的预期设计。我敢肯定,此时我错过了一个相当简单的调整。
如果重要的话,我正在使用一个拥有自己所见即所得前端的站点,并且我对源代码的访问权限有限 - 我可以进行一些更改但不能完全控制,但这就是我一直在使用的。
<style type="text/css">
.tablestyle {
border: #78c0d4 1pt solid;
cellpadding:none;
cellspacing: none;
border: medium none;
border-collapse: collapse;
width: 740;
table-layout: fixed;
}
#heading {
text-align:center;
line-height:normal;
font-size:26px;
font-family: Arial, Helvetica, sans-serif;
color:#252525;
}
.tablerowblue {
border: #78c0d4 1pt solid;
background: #d2eaf1;
border-right-color: #f0f0f0;
vertical-align:top;
line-height: normal;
font-size: 12px;
color: black;
font-family: Arial, Helvetica, sans-serif;
}
.tablerowwhite {
border: #78c0d4 1pt solid;
background: #ffffff;
vertical-align:top;
line-height: normal;
font-size: 12px;
color: black;
font-family: Arial, Helvetica, sans-serif;
}
.tableheadbold {
padding: 0 5px;
border: #78c0d4 1pt solid;
background: #4bacc6;
border-right-color: #f0f0f0;
vertical-align:top;
text-align: center;
font-size: 12px;
color: black;
font-family: Arial, Helvetica, sans-serif;
font-weight:bold;
}
.col1 {
width: 40;
font-weight:bold;
text-align:center;
border: #78c0d4 1pt solid;
}
.col2 {
width:80;
border: #78c0d4 1pt solid;
padding: 0px 5px;
}
.col3 {
width:70;
border: #78c0d4 1pt solid;
padding: 0px 5px;
}
.col4 {
width:170;
border: #78c0d4 1pt solid;
padding: 0px 5px;
}
.col5 {
width:140;
text-align:center;
border: #78c0d4 1pt solid;
padding: 0px 5px;
}
.col6 {
width:190;
color:black;
border: #78c0d4 1pt solid;
padding: 0px 5px;
}
</style>
<div>
</div>
<p id="heading">
Troops</p>
<p>
</p>
<table class="tablestyle">
<tbody>
<tr class="tableheadbold">
<td>
Troop</td>
<td>
Chartered Organization<br />
Meeting Location</td>
<td>
Town/City</td>
<td>
Unit Leader<br />
Comm. Chair</td>
<td>
Phone</td>
<td>
E-Mail</td>
</tr>
<tr class="tablerowwhite">
<td class="col1">
2</td>
<td class="col2">
Grace Episcopal Church</td>
<td class="col3">
Nyack</td>
<td class="col4">
Leader Name 1<br />
Leader Name 2</td>
<td class="col5">
222-1234<br />
333-6789</td>
<td class="col6">
<a href="mailto:johnsmith@optonline.net">johnsmith@optonline.net</a><br />
<a href="mailto:tomjones.net">tomjones.net</a></td>
</tr>
<tr class="tablerowblue">
<td class="col1">
10</td>
<td class="col2">
Atonement Lutheran Church</td>
<td class="col3">
Stony Point</td>
<td class="col4">
Leader Name 1<br />
Leader Name 2</td>
<td class="col5">
222-1234<br />
333-6789</td>
<td class="col6">
<a href="mailto:johnsmith@optonline.net">johnsmith@optonline.net</a><br />
<a href="mailto:tomjones.net">tomjones.net</a></td>
</tr>
</tbody>
</table>