[英]Span inside th width
element in . 我在有带有元素的表。 我想要跨度宽度匹配th,但实际上它填充了整行:(。
我的代码:
for (var i = 0; i < testInfoFieldsNames.length; i++) {
title = testInfoFieldsNames[i].toLowerCase();
th = $('<th></th>');
span = $('<span></span>').addClass('cell-container').text(title);
th.append( span );
}
tableHeader.append(th);
CSS:
.cell-container {
position: absolute;
display: block;
top: 5px;
left: 0;
width: 100%;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
only? 如何设置跨度,以填补只?
请尝试此操作,我认为这对您有用。
请检查此示例链接
for (var i = 0; i < testInfoFieldsNames.length; i++) {
title = testInfoFieldsNames[i].toLowerCase();
th = $('<th><span class="cell-container">'+title+'</span></th>');
}
tableHeader.append(th);
的CSS
span.cell-container {
display: block;
top: 5px;
left: 0;
width: 100%;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
我认为你应该给像这样的风格:
th{
position:relative;
}
标签“ span”是内联元素。 它没有宽度和高度。 您应该使用“ div”或设置以下属性
display:block;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.