我想固定我的按钮的位置,因为当我点击功能ShowContacts
在屏幕上加载和显示联系人列表,我的按钮转到页脚页面;按钮固定位置
#button1 {
position: fixed; // or relative
bottom: 0px;
right: 0px;
}
查看更多有关定位CSS元素:第一http://www.w3schools.com/css/css_positioning.asp
我想固定我的按钮的位置,因为当我点击功能ShowContacts
在屏幕上加载和显示联系人列表,我的按钮转到页脚页面;按钮固定位置
#button1 {
position: fixed; // or relative
bottom: 0px;
right: 0px;
}
查看更多有关定位CSS元素:第一http://www.w3schools.com/css/css_positioning.asp
这是一个CSS问题不是JQuery的,你可以通过添加这种修复。这与jQuery无关。
要解决这个按钮,添加例如下面的CSS:
.btn{
position: fixed;
left: 0;
top: 0:
}
这将其固定在页面的左上角。
我强烈建议你学习CSS第一
延伸阅读:
编辑:
你可以,但是,通过使用jQuery实现这一点:
$('.btn').css({
'position':'fixed',
// more rules
);
第一件事,你的问题是标签不正确
<button class = "btn" type="button" id='button1' style="visibility: hidden" onclick = "showContacts()">Show Contacts</button>
虽然你的回答是正确的,但我想指出以下网站,正如你提到的w3schools。我建议选择其他资源,例如MDN http://w3fools.com/ 此外,相对定位不会修复元素 – Sprottenwels