html - 如何使用 CSS 将 div 元素浮动到屏幕底部?
问题描述
我正在制作一个包含不同部分的网站,一个位于屏幕底部。我首先尝试将 div 元素放在页脚元素中。这没有用。div 仍然在屏幕的顶部。我没有想法,所以我在谷歌上搜索了一个解决方案。我试过的都没有用。我怎样才能做到这一点?
解决方案
如果您需要始终在屏幕上看到您的页脚,或者在页面末尾像这样,这就是答案。解释与zachThePerson 的相同。
.main {
position: relative;
height: 700px;
width: 100%;
background: blue;
}
.box {
position: absolute;
bottom: 0px;
width: 100%;
}
.box1 {
width: 100px;
height: 100px;
background: red;
float: right;
}
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div class="main">
<h1>The float Property</h1>
<p>In this example, the image will float to the right in the text.</p>
<div class="box">
<div class="box1"></div>
</div>
</div>
</body>
</html>
推荐阅读
- reactjs - ElectronJS 打印 HTML 文档高度问题
- python - How do i fix Unresolved attribute reference 'send_message' for class 'Bot'
- reactjs - 如何解决 Apollo 的 Mutation 和 Formik Render Props 之间的相互依赖?
- ios - -Swift.h 头文件中没有名为“AVCaptureVideoDataOutputSampleBufferDelegate”的类型或协议
- angular - 我应该在我的 .ts 代码中添加什么以使 agm-info-window 工作?
- python - PySerial readline() 先返回命令,再返回答案
- reactjs - 流 - 事件类型中缺少属性
- amazon-web-services - 如何升级 Kops 版本
- sbt - 使用宏天堂并与 2.12/2.13 交叉编译
- node.js - 从nodejs中的数据库获取数据时的空值