div { width:300px; height:300px; overflow:scroll; }
#apDiv1 { position:absolute; left:204px; top:145px; width:100px; height:300px; z-index:1; overflow: scroll; } --> 其实很简单就是设置overflow的属性值即可实现效果 auto自动内容多时自动加滚动条 hidden是内容超过设定时隐藏多余的内容
scroll是滚动 还有scroll-x scroll-y是控制上下滚动还是左右滚动的
先给这个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>我们都是中国人<br>我们都是中国人<br>我们都是中国人<br>我们都是中国人<br>我们都是中国人<br>我们都是中国人<br>我们都是中国人<br>我们都是中国人<br>我们都是中国人<br>我们都是中国人<br>我们都是中国人<br>我们都是中国人<br>我们都是中国人<br>我们都是中国人<br></div>
</body>
</html>