【问题标题】:Bootstrap button position at absolute bottom left绝对左下角的引导按钮位置
【发布时间】:2020-07-21 02:57:47
【问题描述】:

我使用 Django 作为 Web 框架和 Bootstrap 以获得更好的前端渲染。我正在尝试在我的页面上放置一个“添加”按钮,该按钮应始终位于左下角。从用户的角度来看,即使在滚动时它也应该固定在角落;并覆盖任何其他内容。

如果可能的话,我想要 Bootstrap 的内置功能并避免自定义 CSS(到目前为止,我还没有)。

我不太明白如何使用here 中描述的引导定位。

这添加了我的按钮,但我该如何配置它的位置? class="position-absolute" 似乎什么也没做。

<div class="position-absolute">
    <a href="{% url 'app:add' %}"><i class="fas fa-plus-circle fa-3x"></i></a>
</div>

【问题讨论】:

  • 可能是其他代码正在影响它。您可以创建一个可重现的演示供我们查看吗?

标签: html css twitter-bootstrap bootstrap-4 css-position


【解决方案1】:
<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>

【讨论】:

【解决方案2】:

这是将左上角的按钮保持为固定项目的示例 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>

注意:请记住包含引导 cdn 链接,以使这些引导类能够正常工作。

您可以使用以下链接来修改类名并查看结果: https://www.w3schools.com/code/tryit.asp?filename=GGY1VBV2YVFP

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-12-22
    • 2013-05-28
    • 2012-05-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-01
    相关资源
    最近更新 更多