html表格宽度整体设置,如何在HTML中设置正确的表格宽度?

在下面的html代码中,我创建了一个表格。但列宽不正确。我也添加了CSS代码和输出图像。请告诉我我错在哪里,为什么表列宽度不相等。提前致谢。如何在HTML中设置正确的表格宽度?

body {

width: 800px;

margin: auto;

margin-top: 100px;

}

header {

background-color: #EC7063;

border-radius: 10px;

text-align: center;

}

main {

background-color: #76D7C4;

border-radius: 10px;

padding: 20px;

}

h1 {

color: #21618C;

}

#cat {

border-radius: 10px;

background-color: #27AE60;

padding: 10px;

margin-right: 20px;

float: left;

height: 200px;

}

h2 {

color: #21618C;

}

#prod {

border-radius: 10px;

background-color: #AF7AC5;

height: 200px;

padding: 10px;

overflow: hidden;

}

table {

display: block;

overflow: auto;

height: 100px;

table-layout: fixed;

width: 100%;

}

table,

th,

td {

border: 1px solid black;

border-collapse: collapse;

}

td {

text-align: center;

}

footer {

background-color: #EC7063;

border-radius: 10px;

text-align: center;

font-size: 25px;

color: #F8F9F9;

clear: both;

}

My Guitar Shop

Product Manager

Product List

Categories

Guitars

CodeNamePriceDelete
guytr0000000546
yuiuyt0000000888
oiiu0000000098

Add Product

© 2017 My Guitar Shop, Inc.

a9N51.png

2017-06-14

KawaiKx

+0

尝试从您的表中删除'display:block' –

+0

试过。尽管它将列宽设置为正确,但它无济于事。它删除滚动。 –

+0

如果您需要更多帮助,请提供实际可用的代码 - 即生成的HTML代码,而不是PHP代码,即使他们尝试过,也无法在系统中正确执行代码。 [mcve] –

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值