div 能控制内容显示多少吗? 多的内容就隐藏或者有滚动条

来源:百度知道 编辑:UC知道 时间:2024/06/08 12:34:04
DIV的容纳内容的高度是 300 ,但是实际内容的 高度是 500

怎么让它显示300的内容,Div又不会被撑开,下面200 的内容也能看到。。。请高手帮忙!!!

先给这个div定个高度,想隐藏的话再加样式:overflow:hidden;如果想有滚动条可在设定div高度后,加样式:overflow:auto;
滚动条的例子:
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>cping's test</title>
</head>

<body>
<div style="width:500px;height:300px;background:pink;overflow:auto;">我们都是中国人<br>我们都是中国人<br>我们都是中国人<br>我们都是中国人<br>我们都是中国人<br>我们都是中国人<br>我们都是中国人<br>我们都是中国人<br>我们都是中国人<br>我们都是中国人<br>我们都是中国人<br>