使用javascript和css设置DIV的滚动高度

Setting scroll height of a DIV using javascript and css

本文关键字:滚动 高度 DIV 设置 javascript css 使用      更新时间:2023-09-26

我有这个div,当一个动作被触发时弹出。当我向下滚动页面时,它仍然停留在页面的顶部。我想设置滚动条的高度,使其相对于页面滚动条移动。简单地将位置设置为相对位置是行不通的。我如何使用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吗?