好奇怪的行为,当它应该工作:

的问题是,如果我不声明一个DOCTYPE的CSS在IE 6&7,但如果我声明DOCTYPE它不起作用。为什么???

jQuery的:

$('tr:first-child').children().css({
   'width': settings.minWidth + 'px',
   'height': settings.tableHeaderHeight + 'px',
   'overflow': 'hidden',
   'white-space': 'nowrap',
   'color': 'blue'
});

HTML瓦特/ DOCTYPE - 请Firefox和IE 6和7查看看表头差

HTML WO / DOCTYPE - 请Firefox和IE 6和7查看看表头差

DOCTYPE我声明了:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

因此,一个有用的评论后,我发现怪异模式正在使用的时候,不添加DOCTYPE,这是CSS效果我想,但有DOCTYPE,唉!

任何变通?建议?

解决方案,是啊!

的jQuery

// This adds a div tag around the table header text 
//  - IE white-space bug in standard mode
$('table.className tr th').wrapInner(
  "<div class='ie_correct_header_whitespace'></div>"
);

CSS

.ie_correct_header_whitespace {
   white-space: nowrap;
}
有帮助吗?

解决方案

首先,我认真建议您使其在标准模式下工作。依托怪癖模式做出任何布局“只是工作”是不是一个很健康的方法。

您可以包装在一个块元素内容,比方说,一个DIV元素,然后把你的DIV在你的表头。 溢出和宽度应该尊重在标准模式的方式,给你想要的效果。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top