表格在不同屏幕尺寸上看起来不统一
Tables not looking uniform on different screen size
我有一个文本填充 table 分为 4 列(如下图所示),显示所有子类别(2 级和 3 级子类别)。 table 在不同的屏幕尺寸(不同的笔记本电脑尺寸)和不同的设备上,即使在我尝试使用@media 查询使其响应后,这个 table 看起来并不统一,有些列看起来比其他列长。有没有办法解决这个问题,让所有的列看起来总是统一的?
我用过媒体
.tblcol {
width: 22%;
text-align: left;
font-size: 11px;
font-family: "Palatino Linotype";
}
.heading {
background-color: #790102;
color: #ffffff;
padding: 2px;
}
a {
text-decoration: none;
}
.slogan {
color: #790102;
letter-spacing: 8px;
font-size: 18px
}
@media(max-width:1023px) {
.categoryTable1 {
width: 500px;
}
}
@media(min-width:1024px) and (max-width:1010px) {
.categoryTable1 {
width: 680px;
}
}
@media(min-width:1011px) and (max-width:1300px) {
.categoryTable1 {
width: 740px;
}
}
@media(min-width:1224px) and (max-width:1400px) {
.categoryTable1 {
width: 850px;
}
}
@media(min-width:1410px) {
.categoryTable1 {
width: 970px;
}
}
<table class="categoryTable1">
<tr>
<td colspan="4">
<p style="text-align:center" class="slogan"> 1500+ ITEMS * 45 PRODUCTS * 14 CATEGORIES </p>
</td>
</tr>
<tr>
<td width="25%" class="tblcol">
<a href="https://www.chinesefashionstyle.com/bespoke-custom-made-services/ " target="_self"> <span class="heading"> BESPOKE CUSTOM MADE SERVICES </span> </a><br>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-women/ " target="_self"> Bespoke Tailoring for Women </a><br>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-men/ " target="_self"> Bespoke Tailoring for Men </a><br>
<a href="https://www.chinesefashionstyle.com/made-to-measure-for-juniors/ " target="_self"> Made to Measure for Juniors </a><br>
<a href="https://www.chinesefashionstyle.com/bespoke-custom-made-services/ " target="_self"> <span class="heading"> BESPOKE CUSTOM MADE SERVICES </span> </a><br>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-women/ " target="_self"> Bespoke Tailoring for Women </a><br>
</td>
<td width="25%" class="tblcol">
<a href="https://www.chinesefashionstyle.com/bespoke-custom-made-services/ " target="_self"> <span class="heading"> BESPOKE CUSTOM MADE SERVICES </span> </a><br>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-women/ " target="_self"> Bespoke Tailoring for Women </a><br>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-men/ " target="_self"> Bespoke Tailoring for Men </a><br>
<a href="https://www.chinesefashionstyle.com/made-to-measure-for-juniors/ " target="_self"> Made to Measure for Juniors </a><br>
<a href="https://www.chinesefashionstyle.com/bespoke-custom-made-services/ " target="_self"> <span class="heading"> BESPOKE CUSTOM MADE SERVICES </span> </a><br>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-women/ " target="_self"> Bespoke Tailoring for Women </a><br>
</td>
<td width="25%" class="tblcol">
<a href="https://www.chinesefashionstyle.com/bespoke-custom-made-services/ " target="_self"> <span class="heading"> BESPOKE CUSTOM MADE SERVICES </span> </a><br>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-women/ " target="_self"> Bespoke Tailoring for Women </a><br>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-men/ " target="_self"> Bespoke Tailoring for Men </a><br>
<a href="https://www.chinesefashionstyle.com/made-to-measure-for-juniors/ " target="_self"> Made to Measure for Juniors </a><br>
<a href="https://www.chinesefashionstyle.com/bespoke-custom-made-services/ " target="_self"> <span class="heading"> BESPOKE CUSTOM MADE SERVICES </span> </a><br>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-women/ " target="_self"> Bespoke Tailoring for Women </a><br>
</td>
<td width="25%" class="tblcol">
<a href="https://www.chinesefashionstyle.com/bespoke-custom-made-services/ " target="_self"> <span class="heading"> BESPOKE CUSTOM MADE SERVICES </span> </a><br>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-women/ " target="_self"> Bespoke Tailoring for Women </a><br>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-men/ " target="_self"> Bespoke Tailoring for Men </a><br>
<a href="https://www.chinesefashionstyle.com/made-to-measure-for-juniors/ " target="_self"> Made to Measure for Juniors </a><br>
</td>
</tr>
</table>
查询更新 table 宽度以适应所需的尺寸。但是当 table 宽度减小时; 4 列不均匀:有些比其他的大很多
.slogan {
color: #790102;
letter-spacing: 8px;
font-size: 18px
}
.heading {
background-color: #790102;
color: #ffffff;
padding: 2px;
}
a {
text-decoration: none;
}
table {
border-collapse: collapse;
width: 100%;
}
td,
th {
text-align: left;
padding: 8px;
font-size: 11px;
font-family: "Palatino Linotype";
}
<table class="categoryTable1">
<tr>
<td colspan="4">
<p style="text-align:center" class="slogan">1500+ ITEMS * 45 PRODUCTS * 14 CATEGORIES</p>
</td>
</tr>
<tr>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-custom-made-services/ " target="_self">
<span class="heading">BESPOKE CUSTOM MADE SERVICES</span>
</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-custom-made-services/ " target="_self">
<span class="heading">BESPOKE CUSTOM MADE SERVICES</span>
</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-custom-made-services/ " target="_self">
<span class="heading">BESPOKE CUSTOM MADE SERVICES</span>
</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-custom-made-services/ " target="_self">
<span class="heading">BESPOKE CUSTOM MADE SERVICES</span>
</a>
</td>
</tr>
<tr>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-women/ " target="_self">Bespoke Tailoring for Women</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-women/ " target="_self">Bespoke Tailoring for Women</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-women/ " target="_self">Bespoke Tailoring for Women</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-women/ " target="_self">Bespoke Tailoring for Women</a>
</td>
</tr>
<tr>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-men/ " target="_self">Bespoke Tailoring for Men</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-men/ " target="_self">Bespoke Tailoring for Men</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-men/ " target="_self">Bespoke Tailoring for Men</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-men/ " target="_self">Bespoke Tailoring for Men</a>
</td>
</tr>
<tr>
<td>
<a href="https://www.chinesefashionstyle.com/made-to-measure-for-juniors/ " target="_self">Made to Measure for Juniors</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/made-to-measure-for-juniors/ " target="_self">Made to Measure for Juniors</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/made-to-measure-for-juniors/ " target="_self">Made to Measure for Juniors</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/made-to-measure-for-juniors/ " target="_self">Made to Measure for Juniors</a>
</td>
</tr>
<tr>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-custom-made-services/ " target="_self">
<span class="heading">BESPOKE CUSTOM MADE SERVICES</span>
</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-custom-made-services/ " target="_self">
<span class="heading">BESPOKE CUSTOM MADE SERVICES</span>
</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-custom-made-services/ " target="_self">
<span class="heading">BESPOKE CUSTOM MADE SERVICES</span>
</a>
</td>
</tr>
<tr>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-women/ " target="_self">Bespoke Tailoring for Women</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-women/ " target="_self">Bespoke Tailoring for Women</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-women/ " target="_self">Bespoke Tailoring for Women</a>
</td>
</tr>
</table>
现在所有的列看起来都是统一的。
HTML 元素定义了 table 中的一行单元格。然后可以使用(数据单元格)和(header 单元格)元素的混合来建立行的单元格。
您可以使用下面的 link 了解有关 HTML table 的更多信息
Click here
我有一个文本填充 table 分为 4 列(如下图所示),显示所有子类别(2 级和 3 级子类别)。 table 在不同的屏幕尺寸(不同的笔记本电脑尺寸)和不同的设备上,即使在我尝试使用@media 查询使其响应后,这个 table 看起来并不统一,有些列看起来比其他列长。有没有办法解决这个问题,让所有的列看起来总是统一的?
我用过媒体
.tblcol {
width: 22%;
text-align: left;
font-size: 11px;
font-family: "Palatino Linotype";
}
.heading {
background-color: #790102;
color: #ffffff;
padding: 2px;
}
a {
text-decoration: none;
}
.slogan {
color: #790102;
letter-spacing: 8px;
font-size: 18px
}
@media(max-width:1023px) {
.categoryTable1 {
width: 500px;
}
}
@media(min-width:1024px) and (max-width:1010px) {
.categoryTable1 {
width: 680px;
}
}
@media(min-width:1011px) and (max-width:1300px) {
.categoryTable1 {
width: 740px;
}
}
@media(min-width:1224px) and (max-width:1400px) {
.categoryTable1 {
width: 850px;
}
}
@media(min-width:1410px) {
.categoryTable1 {
width: 970px;
}
}
<table class="categoryTable1">
<tr>
<td colspan="4">
<p style="text-align:center" class="slogan"> 1500+ ITEMS * 45 PRODUCTS * 14 CATEGORIES </p>
</td>
</tr>
<tr>
<td width="25%" class="tblcol">
<a href="https://www.chinesefashionstyle.com/bespoke-custom-made-services/ " target="_self"> <span class="heading"> BESPOKE CUSTOM MADE SERVICES </span> </a><br>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-women/ " target="_self"> Bespoke Tailoring for Women </a><br>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-men/ " target="_self"> Bespoke Tailoring for Men </a><br>
<a href="https://www.chinesefashionstyle.com/made-to-measure-for-juniors/ " target="_self"> Made to Measure for Juniors </a><br>
<a href="https://www.chinesefashionstyle.com/bespoke-custom-made-services/ " target="_self"> <span class="heading"> BESPOKE CUSTOM MADE SERVICES </span> </a><br>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-women/ " target="_self"> Bespoke Tailoring for Women </a><br>
</td>
<td width="25%" class="tblcol">
<a href="https://www.chinesefashionstyle.com/bespoke-custom-made-services/ " target="_self"> <span class="heading"> BESPOKE CUSTOM MADE SERVICES </span> </a><br>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-women/ " target="_self"> Bespoke Tailoring for Women </a><br>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-men/ " target="_self"> Bespoke Tailoring for Men </a><br>
<a href="https://www.chinesefashionstyle.com/made-to-measure-for-juniors/ " target="_self"> Made to Measure for Juniors </a><br>
<a href="https://www.chinesefashionstyle.com/bespoke-custom-made-services/ " target="_self"> <span class="heading"> BESPOKE CUSTOM MADE SERVICES </span> </a><br>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-women/ " target="_self"> Bespoke Tailoring for Women </a><br>
</td>
<td width="25%" class="tblcol">
<a href="https://www.chinesefashionstyle.com/bespoke-custom-made-services/ " target="_self"> <span class="heading"> BESPOKE CUSTOM MADE SERVICES </span> </a><br>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-women/ " target="_self"> Bespoke Tailoring for Women </a><br>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-men/ " target="_self"> Bespoke Tailoring for Men </a><br>
<a href="https://www.chinesefashionstyle.com/made-to-measure-for-juniors/ " target="_self"> Made to Measure for Juniors </a><br>
<a href="https://www.chinesefashionstyle.com/bespoke-custom-made-services/ " target="_self"> <span class="heading"> BESPOKE CUSTOM MADE SERVICES </span> </a><br>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-women/ " target="_self"> Bespoke Tailoring for Women </a><br>
</td>
<td width="25%" class="tblcol">
<a href="https://www.chinesefashionstyle.com/bespoke-custom-made-services/ " target="_self"> <span class="heading"> BESPOKE CUSTOM MADE SERVICES </span> </a><br>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-women/ " target="_self"> Bespoke Tailoring for Women </a><br>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-men/ " target="_self"> Bespoke Tailoring for Men </a><br>
<a href="https://www.chinesefashionstyle.com/made-to-measure-for-juniors/ " target="_self"> Made to Measure for Juniors </a><br>
</td>
</tr>
</table>
查询更新 table 宽度以适应所需的尺寸。但是当 table 宽度减小时; 4 列不均匀:有些比其他的大很多
.slogan {
color: #790102;
letter-spacing: 8px;
font-size: 18px
}
.heading {
background-color: #790102;
color: #ffffff;
padding: 2px;
}
a {
text-decoration: none;
}
table {
border-collapse: collapse;
width: 100%;
}
td,
th {
text-align: left;
padding: 8px;
font-size: 11px;
font-family: "Palatino Linotype";
}
<table class="categoryTable1">
<tr>
<td colspan="4">
<p style="text-align:center" class="slogan">1500+ ITEMS * 45 PRODUCTS * 14 CATEGORIES</p>
</td>
</tr>
<tr>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-custom-made-services/ " target="_self">
<span class="heading">BESPOKE CUSTOM MADE SERVICES</span>
</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-custom-made-services/ " target="_self">
<span class="heading">BESPOKE CUSTOM MADE SERVICES</span>
</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-custom-made-services/ " target="_self">
<span class="heading">BESPOKE CUSTOM MADE SERVICES</span>
</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-custom-made-services/ " target="_self">
<span class="heading">BESPOKE CUSTOM MADE SERVICES</span>
</a>
</td>
</tr>
<tr>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-women/ " target="_self">Bespoke Tailoring for Women</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-women/ " target="_self">Bespoke Tailoring for Women</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-women/ " target="_self">Bespoke Tailoring for Women</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-women/ " target="_self">Bespoke Tailoring for Women</a>
</td>
</tr>
<tr>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-men/ " target="_self">Bespoke Tailoring for Men</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-men/ " target="_self">Bespoke Tailoring for Men</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-men/ " target="_self">Bespoke Tailoring for Men</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-men/ " target="_self">Bespoke Tailoring for Men</a>
</td>
</tr>
<tr>
<td>
<a href="https://www.chinesefashionstyle.com/made-to-measure-for-juniors/ " target="_self">Made to Measure for Juniors</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/made-to-measure-for-juniors/ " target="_self">Made to Measure for Juniors</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/made-to-measure-for-juniors/ " target="_self">Made to Measure for Juniors</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/made-to-measure-for-juniors/ " target="_self">Made to Measure for Juniors</a>
</td>
</tr>
<tr>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-custom-made-services/ " target="_self">
<span class="heading">BESPOKE CUSTOM MADE SERVICES</span>
</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-custom-made-services/ " target="_self">
<span class="heading">BESPOKE CUSTOM MADE SERVICES</span>
</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-custom-made-services/ " target="_self">
<span class="heading">BESPOKE CUSTOM MADE SERVICES</span>
</a>
</td>
</tr>
<tr>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-women/ " target="_self">Bespoke Tailoring for Women</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-women/ " target="_self">Bespoke Tailoring for Women</a>
</td>
<td>
<a href="https://www.chinesefashionstyle.com/bespoke-tailoring-for-women/ " target="_self">Bespoke Tailoring for Women</a>
</td>
</tr>
</table>
现在所有的列看起来都是统一的。 HTML 元素定义了 table 中的一行单元格。然后可以使用(数据单元格)和(header 单元格)元素的混合来建立行的单元格。 您可以使用下面的 link 了解有关 HTML table 的更多信息 Click here