【问题标题】:sticky footer not staying at the bottom after I scroll滚动后,粘性页脚不会停留在底部
【发布时间】:2019-04-23 10:17:44
【问题描述】:
  • 我正在尝试开发一个粘性页脚。
  • 当您点击添加新的体育运动按钮时,一个抽屉会在该页脚中打开并停留在底部
  • 但是当我滚动页面时,页脚向上移动。
  • 我尝试了各种职位,但仍然无法正常工作。你能告诉我如何解决它。 -在下面提供我的代码 sn-p、沙箱和屏幕截图。

https://codesandbox.io/s/jp82jl853v

 sportsEditTabContentFooter: {
    position: "fixed",
    left: 0,
    bottom: 0,
    width: "100 %",
    backgroundColor: "red",
    color: "white",
    textAlign: "center"
  },


  <div className={classes.sportsEditTabContentFooter}>
              <div>sports Status</div>
              <div>
                <Button variant="outlined" className={classes.button}>
                  Cancel
                </Button>
                <Button
                  variant="outlined"
                  onClick={this.savesports}
                  className={classes.button}
                >
                  Save sports test
                </Button>
              </div>
            </div>

【问题讨论】:

标签: javascript html css reactjs material-ui


【解决方案1】:

查看您的代码后,您似乎还没有将 position:sticky 应用于 div。如果您添加它,您应该注意到它会粘在您放置的位置。

.RecipeReviewCard-sportsEditTabContentFooter-649 {
    left: 0;
    width: 100%;
    color: white;
    bottom: 0;
    text-align: center;
    background-color: red;
    position: sticky;
}

【讨论】:

  • 嘿,它成功了,谢谢,你能帮我解决这个问题吗stackoverflow.com/questions/53265169/…
  • @injiinji 这是什么态度?在强制回答另一个问题之前,您至少应该接受这个答案!
  • 另外,如果您复制此代码,请确保删除 @robert-perez 可能忽略的重复位置声明;)
  • 好电话 gearsdigital,我将对其进行编辑以确保没有人感到困惑。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-03-07
  • 2013-07-27
  • 2013-06-07
  • 2022-12-05
  • 2015-01-28
  • 2012-09-10
相关资源
最近更新 更多