laravel - 使用 Laravel 使用 Bootstrap 4 类创建粘性页脚
问题描述
我想使用 Laravel 6 和 Bootstrap 4 创建一个粘性页脚。我尝试创建它但失败了。这些是我的文件:
布局.blade.php:
<body>
@auth
@include('../inc/navbar')
@endauth
<div class="container" id="app">
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
@csrf
</form>
@yield('content')
</div>
@auth
@include('../inc/footer')
@endauth
</body>
页脚.blade.php:
<nav class="navbar fixed-bottom bg-custom justify-content-end">
<b>Powered by Me</b>
</nav>
应用程序.scss
body {
background-color: rgb(241, 230, 131);
}
nav {
height: 50px;
background-color: rgb(131, 215, 241);
}
我尝试使用 fixed-bottom 类,但通过这种方式,即使用户滚动包含大量内容的页面,页脚也始终保持在屏幕底部的相同位置。有人能帮我吗?
解决方案
根据文档,标记应如下所示。请参见此处的示例。下面示例中的mt-auto
类 ( ) 将元素粘贴到页面底部。margin-top:auto
您已经添加了不需要的nav
和类,尽管如果您愿意的话,您可能可以使用 来实现它。fixed-bottom
fixed-bottom
<footer class="footer mt-auto py-3">
<div class="container">
<span class="text-muted">Place sticky footer content here.</span>
</div>
</footer>
如果您仍然遇到问题,请确保您的标记经过验证,以确保您没有错误的 html
推荐阅读
- cocoapods - 是什么控制 CocoaPods 是显示登录页面还是仅显示 Git 存储库的链接?
- sql - 连接到多个服务器和数据库并运行相同的 SQL 语句
- vega - 在 vega 中将纪元时间戳转换为日期
- phpspreadsheet - 如何不使用 phpspreadsheet html 阅读器在单元格值中写入注释
- jenkins-pipeline - 在 Jenkinsfile 脚本内的字符串中添加括号会导致语法错误
- python - 如何使用 Tensorboard 绘制损失和准确度
- sql - 如何改进/加速 SQL 查询
- iis - 使用不同别名登录时,相同的 IIS 本地主机标记为不同的名称
- image-processing - 为两个大致相同的蒙版图像创建单应矩阵
- c# - 无法让 costura.fody 将 dll 嵌入 exe