javascript - 滚动到页面底部时如何使按钮停留在页脚上方

标签 javascript css twitter-bootstrap

我有一个“反馈”按钮。应始终显示在屏幕的左下方。 The Feedback button

除非你即将到达页脚,否则它应该保持在顶部,

enter image description here

并且在继续查看页脚时不继续向下滑动。

enter image description here

这是我的 HTML 标记:

    <div class="TMDOQ-tab navbar-fixed-bottom">
  <a href="#" id="TMDOQ_button">
          <img src= "assets/TMDOQ.png" alt= "Logo-DitoMismo" class="hidden-phone" id="logoTMDOQ">
        </a>
  <div class="TMDOQ-form">
  <fieldset>
    <div class="control-group">
      <label class="control-label">First name:</label>
        <div class="controls">
          <input type="text" placeholder="Type something…">
        </div>          
    </div>
    <div class="control-group">
      <label class="control-label">Email Address:</label>
      <div class="controls">
        <input type="text" placeholder="Type something…">
      </div>
    </div>
    <div class="control-group">
      <label class="control-label">Cellphone Number:</label>
      <div class="controls">
        <input type="text" placeholder="Type something…">
      </div>
    </div>
    <div class="control-group">
      <label class="control-label">Item Name:</label>
      <div class="controls">
        <input type="text" placeholder="Type something…">
      </div>
    </div>
    <div class="control-group">
      <button type="submit" class="btn-primary">Submit</button>
    </div>
  </fieldset>
  </div>
</div>

CSS 代码:

 .TMDOQ-tab
{
    position:absolute;
    left:0;
    bottom:0;

}
.TMDOQ-tab a 
{
    display:block;
    height:20px;
    width:100px;
    text-align:center;
    background: url('../img/header-footer.png');


    padding:8px;
    float:left;
    cursor:pointer;
    /*Font*/
    color:#FFF;
    font-weight:bold;
    font-size:18px;


    -webkit-border-radius: 0 20px 0 0;
            border-radius: 0 20px 0 0;
    background-clip: padding-box;


}
.TMDOQ-tab .TMDOQ-form
{
    clear:both;
    height:auto;
    width:auto;

    background: url('../img/header-footer.png');
    padding:30px;
    display: none;

    -webkit-border-radius: 0 20px 0 0;
            border-radius: 0 20px 0 0;
    background-clip: padding-box;

}

当我使用 JS 时:

$("#TMDOQ_button").click(function()
{
        $('.TMDOQ-form').slideToggle();
});

我认为这是我正在尝试做的最接近的事情,尽管他们使用的是我不知道如何在我的代码中实现的 jQuery,但我不需要完整的侧边栏,我只需要反馈按钮贴在屏幕的左下方,当靠近页脚区域时,它会停在它上面。

lockedfixed.js

最佳答案

使用固定在底层的位置

 .TMDOQ-tab navbar-fixed-bottom
    {
    position: fixed;
    }

关于javascript - 滚动到页面底部时如何使按钮停留在页脚上方,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17917974/

相关文章:

html - IE 选择框选项元素高度不起作用

javascript - 使用 javascript 在表中创建子标题

twitter-bootstrap - 将弹出窗口与 JStree 一起使用

html - bootstrap no-gutter 网格系统不工作

javascript - 重置元素 'odd' 或 'even' 状态?

javascript - 区域设置语言缩减器

javascript - jQuery 中的循环

javascript - 使用 angularjs 的图库弹出窗口不起作用,但使用 javascript 工作正常

jquery - 如何将超链接添加到表格行 <tr>

javascript - 多级折叠侧边栏箭头方向改变