<th>和<td>标签的width和height属性无法设置....亲测有效

解决table标签下的和属性宽和高设置无效

在写table表格框的时候,会遇到自己的属性设置了width: :属性和height:;属性,可预览的时候不会有任何的变化,你的表格还是一团没有任何的可看性。废话不多说,我们一起来看看吧

table{
		
    	table-layout: fixed;
}

只要在table标签里设置table-layout属性值为fixed,然后在设置width和height属性就可以改变了。

事例如下:亲测有效

table{
		border: deepskyblue;
    	min-width: 100%;
    	table-layout: fixed;
}

	#table-head{
    	overflow:auto;
    	display: block;
}

</style>
</head>
<div id="product_table">
<body background="sources/3.jpg">
	<div id="table-head">
	<table width="100px" height="60px" border="1" cellspacing="0" cellpadding="0">
		<tr>
			<th width="100px">商品图片</th>
			<th width="100px">产品名</th>
			<th width="100px">店铺价格</th>
			<th width="100px">商品信息</th>
			<th width="100px">热门</th>
			<th width="100px">描述</th>	
		</tr>
	<tr>
		<td></td>
		
	</tr>
	</table>
下面我们来看看为什么要这样设置

通过查阅资料,知道了table-layout属性有
①automatic:(默认值)列宽度由单元格内容设定;

②fixed: 列宽由表格宽度和列宽度设定;

③inherit:规定应该从父元素继承table-layout属性的值。
这三个属性。
其中automatic为默认值,也就是说如果你不设置table-layout的属性,那么默认就是automatic值,而automatic值指定了table框内的与的width和height值为固定表格设定,所以此时你不能改变它两的值。把它设置为fixed值时为自动定表格布局,这时候就可以自由的设定width和height属性了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值