最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to make a button stay at a bottom of a screen? - Stack Overflow

programmeradmin3浏览0评论

I've got a button that I want to stay at the bottom of the screen, no matter how you scroll the page up or down the page. I need it to stay a fixed distance away from the bottom of the window.

How do I make it sticky like this?

I've got a button that I want to stay at the bottom of the screen, no matter how you scroll the page up or down the page. I need it to stay a fixed distance away from the bottom of the window.

How do I make it sticky like this?

Share Improve this question edited Nov 9, 2016 at 18:25 gunr2171 17.6k26 gold badges66 silver badges100 bronze badges asked May 4, 2015 at 9:15 Mo-AlantehMo-Alanteh 3613 gold badges4 silver badges11 bronze badges 2
  • <div style="position:fixed;bottom:0;left:0;">Basic</div> – Andreas Louv Commented May 4, 2015 at 9:17
  • Try this: button { position:relative; margin-top:100%; left:50%; } Link: jsfiddle/JavaUIDeveloper/y4PZ6/248 – Kurenai Kunai Commented May 4, 2015 at 9:38
Add a ment  | 

4 Answers 4

Reset to default 5

To keep any element fixed on page irrelevantto scroll you need to make it position fixed

Please check below CSS

button {
    position: fixed;
    bottom: 0;
    right: 0;
}

CSS

button {
  position: fixed;
  bottom: 10px;
  right: 10px;
}

something like that.

just add below css:

button{
    position:fixed;
    left:10px;
    bottom:10px;
}

To keep the button fixed at the bottom of the page even when scrolled:

button { 
  position:relative; 
  margin-top:100%; 
  left:50%; 
} 

JSFiddle

To position button at the bottom of the page but move with the scroll:

button{
        position:absolute;
        bottom: 5%;
        right:50%;
    }

JSFiddle

发布评论

评论列表(0)

  1. 暂无评论