日期:2014-05-16  浏览次数:20399 次

关于滚动条跟随滚动的问题
如下,我想实现select被选择的项变换时,滚动条自动滚到对应的位置
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>1</title>
<style type="text/css">
table{ 
border-collapse:collapse; 

.sortcolumn
{
  height:12px;
  width:40px;
  border:1px groove #ACA899;
  background-color:#EEEBD9;
  color:#000000;
  font-size:12px;
  text-align:center;
  }
 .tt
 {
  border:0px groove #ACA899;

 }
</style> 
</head>

<body>
<div style="width:100%;height:100;overflow-x:hidden;overflow-y:scroll">

<table border="1" width="100%" id="table1" cellspacing="0" cellpadding="0">
<tr>
<td class="sortcolumn" width="45">1</td>
<td rowspan="8" align=left valign=top>
<SPAN style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; OVERFLOW: hidden; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px; POSITION: absolute">  
  <SELECT style="MARGIN: -3px" multiple size=10>  
  <OPTION>1111</OPTION>  
  <OPTION>11111111111111</OPTION>  
  <OPTION>11111111111111</OPTION>  
  <OPTION>11111111111111</OPTION>  
  <OPTION>11111111111111</OPTION>  
  <OPTION>11111111111111</OPTION>  
  <OPTION>11111111111111</OPTION>  
  <OPTION>11111111111111</OPTION>  
  <OPTION>11111111111111</OPTION>  
  <OPTION>111111111</OPTION>  
  </SELECT></SPAN>  
  </td>
</tr>
<tr>
<td class="sortcolumn" width="45">2</td>
</tr>
  <tr>
<td class="sortcolumn" width="45">3</td>
</tr>
<tr>
<td class="sortcolumn" width="45">4</td>
</tr>
<tr>
<td class="sortcolumn" width="45">5</td>
</tr>
<tr>
<td class="sortcolumn" width="45">6</td>
</tr>
<tr>
<td class="sortcolumn" width="45">7</td>
</tr>
<tr>
<td class="sortcolumn" width="45">8</td>
</tr>

</table>
</div>


------解决方案--------------------
Select onchange的时候=document.getElementById(div的Id).scrollTop=10