Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
打印CSS不考虑显式高度/溢出:无?_Css_Printing_Overflow_Html - Fatal编程技术网

打印CSS不考虑显式高度/溢出:无?

打印CSS不考虑显式高度/溢出:无?,css,printing,overflow,html,Css,Printing,Overflow,Html,我为我的页面编写了一个单独的media=“print”样式表,专门用于调整div的大小。在print CSS中,我为div指定了一个明确的高度(以“pt”为单位)和一个不同的字体大小(也以“pt”为单位)。我还指定div始终具有overflow:hidden(我希望额外的文本被截断) 当我打印页面时,div似乎并不尊重显式的高度——它只是拉伸div(尽管有overflow:hidden);由于这是一个打印布局,我花了很长时间来解决它,因为我不能使用IE开发工具来跟踪CSS/DOM 顺便说一句,我

我为我的页面编写了一个单独的media=“print”样式表,专门用于调整div的大小。在print CSS中,我为div指定了一个明确的高度(以“pt”为单位)和一个不同的字体大小(也以“pt”为单位)。我还指定div始终具有overflow:hidden(我希望额外的文本被截断)

当我打印页面时,div似乎并不尊重显式的高度——它只是拉伸div(尽管有overflow:hidden);由于这是一个打印布局,我花了很长时间来解决它,因为我不能使用IE开发工具来跟踪CSS/DOM

顺便说一句,我正在使用IE8,页面处于兼容模式。我在一个公司局域网中,所有用户区域都保证有IE7或IE8,所以我实际上只需要它在这些区域工作

HTML:

屏幕截图(先浏览,然后IE的“打印预览”):

知道发生了什么事吗?是否存在无法使用溢出:隐藏或设置显式高度的打印布局的“陷阱”?

注意:由于我看不到您的图片,所以回答有点盲目

尝试使用
max height
而不是
height
。这对我有用

编辑 问题在于兼容性模式:它的行为类似于IE6:高度被视为最小高度(即“可以变大”)

完整测试用例:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
    <title>test</title>
    <style type="text/css" media="screen">
        div {
            border: 1px solid red; overflow:hidden;
            float:left;
            width:100%;
            height:50pt
        }
    </style>
    <style type="text/css" media="print">
        div {
            border: 1px solid blue; overflow:hidden;
            float:left;
            width:100%;
            height: 50pt
        }
    </style>
</head>
<body>
        <div>
            test<br />test<br />test<br />test<br />test<br />test<br />test<br />
            test<br />test<br />test<br />test<br />test<br />test<br />test<br />
        </div>
</body></html>

测试
div{
边框:1px纯红;溢出:隐藏;
浮动:左;
宽度:100%;
高度:50磅
}
div{
边框:1px纯蓝色;溢出:隐藏;
浮动:左;
宽度:100%;
高度:50磅
}
测试
测试
测试
测试
测试
测试
测试
测试
测试
测试
测试
测试
测试
测试
测试
测试

Hmmm,仍然有相同的行为。我也在页面上做一些JS的东西。我不知道这是不是害死它的原因。谢谢你的回复!啊,快照,我忘记了兼容模式。。。问题是在此模式下,
高度
被视为
最小高度
。我设法让它和浮子一起工作。更新了我的测试用例。
#notes_html, #overview_html { height: 200pt !important; overflow: hidden; font-size: 12pt; }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
    <title>test</title>
    <style type="text/css" media="screen">
        div {
            border: 1px solid red; overflow:hidden;
            float:left;
            width:100%;
            height:50pt
        }
    </style>
    <style type="text/css" media="print">
        div {
            border: 1px solid blue; overflow:hidden;
            float:left;
            width:100%;
            height: 50pt
        }
    </style>
</head>
<body>
        <div>
            test<br />test<br />test<br />test<br />test<br />test<br />test<br />
            test<br />test<br />test<br />test<br />test<br />test<br />test<br />
        </div>
</body></html>