限制div高度当内容多了溢出时显示滚动条
内容摘要
复制代码代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlnshtmlxmlns
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlnshtmlxmlns
文章正文
复制代码
代码如下:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlnshtmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type"content="text/html; charset=utf-8" />
<title>限制div高度,内容多了显示滚动条</title>
<style type="text/css">
div{ border-radius:5px;border:1px solidred;padding:10px;}
#test{min-height:250px;overflow-y:auto;max-height:300px;}
</style>
</head>
<body>
<div>
<div id="test">
<table>
<tr><td>1</td></tr><tr><td>2</td></tr>
<tr><td>3</td></tr><tr><td>4</td></tr>
<tr><td>5</td></tr><tr><td>6</td></tr>
<tr><td>7</td></tr><tr><td>8</td></tr>
<tr><td>9</td></tr><tr><td>10</td></tr>
<tr><td>5</td></tr><tr><td>6</td></tr>
<tr><td>7</td></tr><tr><td>8</td></tr>
<tr><td>9</td></tr><tr><td>10</td></tr>
</table>
</div>
</div>
</body>
</html>
代码注释