【问题标题】:Positioning copyright footer to the bottom of Angular / C# application using Bootstrap 4使用 Bootstrap 4 将版权页脚定位到 Angular / C# 应用程序的底部
【发布时间】:2023-03-26 09:02:01
【问题描述】:

我正在努力使用 bootstrap 中的sticky-footer-wrapper,以便页脚保持在页面底部。但是,它只是在页面内容结束后出现。这是我的Index.cshtml

@{
    Layout = null;
}

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>XXXX</title>
    <base href="/">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" type="image/x-icon" href="favicon.ico">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link href="/Content/ionicons.min.css" rel="stylesheet" />
    <script src="https://npmcdn.com/angular2/es6/dev/src/testing/shims_for_IE.js"></script>
</head>
<body>

    <div class="d-flex flex-column sticky-footer-wrapper">

            <app-root></app-root>

        <footer class="container-fluid w-100 bg-info text-light py-3">
            <div id="copyright">
                <a target="_blank" href="https://www.company.net/"><img src="/Content/img/xxxlogo_footer.png" alt="xxx Footer Logo" /></a>
                <span>xx.com is the global source of information about and access to services provided by the xxx companies.</span>
                <span class="pull-right copyright">&copy; 2019 xxxgroup Inc.</span>
            </div>
        </footer>
    </div>


    <script type="text/javascript" src="~/Scripts/client/runtime.js"></script>
    <script type="text/javascript" src="~/Scripts/client/polyfills.js"></script>
    @if (HttpContext.Current.IsDebuggingEnabled)
    {
        <script type="text/javascript" src="~/Scripts/client/styles.js"></script>
        <script type="text/javascript" src="~/Scripts/client/vendor.js"></script>
    }
    <script type="text/javascript" src="~/Scripts/client/main.js"></script>
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>

对于组件模板它不起作用我试图通过将内容包装在容器中来在底部添加间距/填充

<div class="container mb-3 pb-3" ></div>

但它仍然无法正常工作。请指导。

【问题讨论】:

  • 为什么将整个脚本和 css 放在 index.cshtml 中而不是 layout.cshtml 中?
  • Tony,老实说,我按照一些示例教程来设置项目。那么您是否建议应用 layout.cshtml 中的页脚?

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


【解决方案1】:

参加 cmets 后编辑

vh-100 添加到外部 div 以使其最初拉伸到视口大小,然后在第一个元素中添加mb-auto,以便将footer 推到底部。

这是一个例子。

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

<body>
  <div class="d-flex flex-column vh-100">
    <app-root class="mb-auto"></app-root>
    <footer class="container-fluid w-100 bg-info text-light py-3">
      <div id="copyright">
        <span>xx.com is the global source of information about and access to services provided by the xxx companies.</span>
        <span class="pull-right copyright">&copy; 2019 xxxgroup Inc.</span>
      </div>
    </footer>
  </div>
</body>

【讨论】:

  • 这比我有的要好,但是当我向上或向下滚动页面时,页脚保持固定并且始终在内容顶部可见。不像标题,在这种情况下您向下滚动页面并且标题不固定。我想要例如行为。这个 stackoverflow 页面。
  • nash11,非常感谢。节省了我很多时间
猜你喜欢
  • 1970-01-01
  • 2018-04-26
  • 1970-01-01
  • 1970-01-01
  • 2019-07-09
  • 2018-11-13
  • 1970-01-01
  • 2014-02-14
相关资源
最近更新 更多