-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[html] 第43天 如何让元素固定在页面底部?有哪些比较好的实践? #161
Comments
直接使用
|
这个是在结构的底部还是视图的底部 ,视图底部就是 fixed,结构的底部就是 sticky footer 布局咯~ |
这个题目应该是实现这一的情况的
|
sticky footer布局:当头部区块和内容区块内容较少时,页脚能固定在屏幕的底部,而非随着文档流排布;当页面内容较多时,页脚能随着文档流自动撑开,显示在页面的最底部 使用flex布局实现 .wrapper {
display: flex;
flex-direction: column;
overflow: auto;
}
.content {
flex: 1;
}
.footer {
flex: 0;
} |
|
移动端使用position:fixed的时候,有时候会出现点击输入拉起键盘时,按钮位置被顶上去,输入完成收起键盘后,位置依旧存在问题的情况 |
{ //在body下设置position: relative; padding-botton: footer的高度/height: calc(100% - footer的高度) .wrapper { } } |
|
position:fixed; |
要让元素固定在页面底部,可以使用CSS的定位属性和一些技巧来实现。以下是一些常用的方法和实践:
.bottom-element {
position: absolute;
bottom: 0;
}
.bottom-element {
position: fixed;
bottom: 0;
}
.container {
display: flex;
justify-content: flex-end;
}
.bottom-element {
position: sticky;
bottom: 0;
} 需要注意的是,使用这些方法时,确保元素的父元素具有足够的高度以容纳固定在底部的元素。此外,还要考虑页面布局和其他元素的影响,以确保固定在底部的元素不会遮挡其他内容。 根据具体的需求和设计,选择适合的方法来实现元素固定在页面底部,并根据需要进行适当的样式调整。 |
第43天 如何让元素固定在页面底部?有哪些比较好的实践?
The text was updated successfully, but these errors were encountered: