Html 防止DIV高度超过某个值
我有一个长文本包装在Html 防止DIV高度超过某个值,html,css,Html,Css,我有一个长文本包装在DIV中,它在TD中。 TD宽度固定为90px,DIV最大高度为60px。 在Chrome和FireFox中是可以的,它是60px x 90px,有一个垂直滚动条,但在InternetExplorer中,DIV高度调整为文本长度,没有滚动条 我希望div的高度能够调整到最大60px,如果内容更大,则有一个滚动条。在Chrome、FireFox和InternetExplorer11中 <html> <head> <style>
DIV
中,它在TD
中。
TD
宽度固定为90px
,DIV最大高度为60px
。
在Chrome和FireFox中是可以的,它是60px x 90px,有一个垂直滚动条,但在InternetExplorer中,DIV高度调整为文本长度,没有滚动条
我希望div的高度能够调整到最大60px,如果内容更大,则有一个滚动条。在Chrome、FireFox和InternetExplorer11中
<html>
<head>
<style>
.medium {
width:90px;
max-width:90px;
overflow: auto;
word-break: break-all;
}
div.scrollable {
overflow:auto;
max-height:60px; /* 3 lines maximum */
height:60px;
text-align:left;
white-space: pre-wrap; /* preserve the text formatting */
}
</style>
</head>
<body>
<table>
<tr>
<td class="medium">
<div class="scrollable">In my design I've multiple Div that contain some text and one of them is a lot bigger that the height of a normal screen resolution. In my design I've multiple Div that contain some text and one of them is a lot bigger that the height of a normal screen resolution.In my design I've multiple Div that contain some text and one of them is a lot bigger that the height of a normal screen resolution.In my design I've multiple Div that contain some text and one of them is a lot bigger that the height of a normal screen resolution.</div>
</td>
</tr>
</table>
</body>
</html>
.中等{
宽度:90px;
最大宽度:90px;
溢出:自动;
单词break:打破一切;
}
可滚动分区{
溢出:自动;
最大高度:60px;/*最大3行*/
高度:60px;
文本对齐:左对齐;
空白:预换行;/*保留文本格式*/
}
在我的设计中,我有多个Div,其中包含一些文本,其中一个比普通屏幕分辨率的高度大得多。在我的设计中,我有多个包含一些文本的Div,其中一个比正常屏幕分辨率的高度大得多。在我的设计中,我有多个包含一些文本的Div,其中一个比正常屏幕分辨率的高度大得多。在我的设计中,我有多个包含一些文本的Div,其中一个更大这是正常屏幕分辨率的高度。
你在看哪个IE版本?我使用的是IE11,工作正常。看这里,你能提供这个问题的截图吗@Ionut如果您正在使用DOCTYPE,请查看链接,它可能会有所帮助@RajeshMadhu非常感谢这解决了我的问题