[英]td widths are not applied on auto width table
Please look at this fiddle http://jsfiddle.net/LHsLM/1/ . 请查看此小提琴http://jsfiddle.net/LHsLM/1/ 。
I am trying to apply height and width to a auto width table using inline css as in the fiddle. 我试图像小提琴一样使用内联css将高度和宽度应用于自动宽度表。 But the styles are not applied.
但是没有应用样式。
html: HTML:
<div id="a"></div>
css: CSS:
div {
height:300px;
width:500px;
overflow:auto;
}
js: JS:
var str = ["<table>"];
for (var i = 0; i < 100; i++) {
var tr = "<tr>";
for(var j = 0; j < 100; j++){
tr += "<td style='width:120px;height:40px'>" + j + "</td>";
}
tr+="</tr>";
str.push(tr);
}
str.push("</table>");
document.getElementById('a').innerHTML = str.join('');
Convert width
to min-width
of your td elements. 转换
width
到min-width
的TD元素。
Sorry, that is not IE-8 compatible. 抱歉,与IE-8不兼容。
This method works for IE8 too: 此方法也适用于IE8:
function tablo(){
var str = ["<table>"];
for (var i = 0; i < 100; i++) {
var tr = "<tr>";
for(var j = 0; j < 100; j++){
tr += "<td><div style='width:120px;height:40px'>" + j + "</div></td>";
}
tr+="</tr>";
str.push(tr);
}
str.push("</table>");
document.getElementById('a').innerHTML = str.join('');
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.