我有这个 div,它会在触发操作时弹出。当我向下滚动页面时,它仍然位于页面顶部。我想设置滚动高度,使其移动到页面滚动的相对位置。简单地定位 : relative 是行不通的。我怎样才能使用javascript得到这个?帮助。
<form name="" action="" method="POST">
<div id='divSearchAndReplace'>
<table id='divSearchAndReplace_Header' width='100%'>
<tr>
<td>
<table>
<tr>
<td align='left'></td>
</tr>
</table>
</td>
</tr>
</table>
<table width='100%' border='0' cellspacing="4" cellpadding="2">
<tr><td colspan='2' nowrap height='10px'></td></tr>
<tr valign="top">
</tr>
<tr><td colspan='2' align='right' style='padding-right:12px;'><input class='form_button' type='submit' name='btnSubmit' value='Replace' onclick='return checkSearchAndReplace();'/></td></tr>
</table>
</div>
</form>
这是CSS
#divSearchAndReplace { width:450px; height:240px; border:1px solid #336699; background-color:#ffffff; position:absolute; left:200px; top:75px; display:none; }
#divSearchAndReplace table { width:450px; border:0px; align:center; }
最佳答案
您是否正在寻找 CSS 中的 position: fixed
?
关于javascript - 使用javascript和css设置DIV的滚动高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8104050/