Bootstrap 按钮位置在绝对左下角
Bootstrap button position at absolute bottom left
我使用 Django 作为 Web 框架,Bootstrap 用于更好的前端渲染。我试图在我的页面上放置一个“添加”按钮,该按钮应始终位于左下角。从用户的角度来看,即使在滚动时它也应该固定在角落;并覆盖任何其他内容。
如果可能,我想要 Bootstrap 的内置功能并避免自定义 CSS(到目前为止,我没有)。
我不太明白如何使用 bootstrap 描述的定位 here。
这添加了我的按钮,但我该如何配置它的位置? class="position-absolute"
好像什么都没做。
<div class="position-absolute">
<a href="{% url 'app:add' %}"><i class="fas fa-plus-circle fa-3x"></i></a>
</div>
<a href="{% url 'app:add' %}" style="position:absolute;bottom:5px;left:5px;margin:0;padding:5px 3px;"><i class="fas fa-plus-circle fa-3x"></i></a>
这里是示例 html 代码,它使按钮位于左角作为固定项。
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"
integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6"
crossorigin="anonymous"></script>
<title>Bootstrap Text Utilities</title>
</head>
<body>
<div class="container">
<h1 class="text-center">Tittle</h1>
<div class="fixed-bottom">
<button class='btn btn-primary'>Fixed bottom</button>
</div>
</div>
</body>
</html>
注意:请记住包含 bootrap cdn links 以使这些 boostrap classes 工作。
您可以使用下面的 link 修改 class 名称并查看结果:
https://www.w3schools.com/code/tryit.asp?filename=GGY1VBV2YVFP
我使用 Django 作为 Web 框架,Bootstrap 用于更好的前端渲染。我试图在我的页面上放置一个“添加”按钮,该按钮应始终位于左下角。从用户的角度来看,即使在滚动时它也应该固定在角落;并覆盖任何其他内容。
如果可能,我想要 Bootstrap 的内置功能并避免自定义 CSS(到目前为止,我没有)。
我不太明白如何使用 bootstrap 描述的定位 here。
这添加了我的按钮,但我该如何配置它的位置? class="position-absolute"
好像什么都没做。
<div class="position-absolute">
<a href="{% url 'app:add' %}"><i class="fas fa-plus-circle fa-3x"></i></a>
</div>
<a href="{% url 'app:add' %}" style="position:absolute;bottom:5px;left:5px;margin:0;padding:5px 3px;"><i class="fas fa-plus-circle fa-3x"></i></a>
这里是示例 html 代码,它使按钮位于左角作为固定项。
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"
integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6"
crossorigin="anonymous"></script>
<title>Bootstrap Text Utilities</title>
</head>
<body>
<div class="container">
<h1 class="text-center">Tittle</h1>
<div class="fixed-bottom">
<button class='btn btn-primary'>Fixed bottom</button>
</div>
</div>
</body>
</html>
注意:请记住包含 bootrap cdn links 以使这些 boostrap classes 工作。
您可以使用下面的 link 修改 class 名称并查看结果: https://www.w3schools.com/code/tryit.asp?filename=GGY1VBV2YVFP