我在一个页面上有一个Asp:textbox(该页面也有一些不同的控件和div),我正在上面设置事件"onkeyup"上的style=position:absolute。并根据文本框中输入的Chartres动态增加其高度。但问题是,当用户向下或向上滚动页面时,文本框的位置始终保持固定。"在事件"onblur"上,我更改了style=position=",但当焦点在文本框上时,它会随着向上/向下滚动而移动。这是代码
<asp:TextBox ID="txtComment1" runat="server" Height="13px" Width="99%" MaxLength="40" TextMode="MultiLine"
onkeyup="SetHeight(this)" onblur="Blur(this)"></asp:TextBox>
<script type="text/javascript">
//Setheight function is used to change the style of position:"Absolute"
function Setheight(textscroll) {
textscroll.style.height = "14px";
textscroll.style.position = "absolute";
textscroll.style.width = "49%";
}
//Blur is used to again change the style position:""
function Blur(txtdesc1) {
txtdesc1.style.height = "14px";
txtdesc1.style.position = "";
txtdesc1.style.width = "99%";
}
</script>
附言:我试过HoverMenuExtender,但仍然有同样的问题
如果你想让一个html项目在滚动时跟随页面向下,请尝试position:fixed,这就是LinkedIn和FB等网站上所有粘贴页眉和页脚的工作方式。