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

标签 javascript html css

我有这个 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/

相关文章:

javascript - 在 mounted() 中阻止应用程序,直到使用 Amazon cognito 和 Vue.js 对用户进行身份验证

javascript - JSF Prevent commandLink 重新加载页面

html - 3 列 css 模板,右列的位置不正确

html - 最小高度不适用于 body

javascript - 学习 JavaScript : Is there a way to change the image file of a group of images without using individual ids?

javascript - 如果正则表达式模式匹配,则字符串中的粗体字

html - 如何使字母像在线框中那样显示?

html - 在 html 中设置表格样式

html - Chrome 缩小打破了线性渐变背景

javascript - 在新窗口中显示 pdf 流