为什么整个html主体卡在视口顶部?

问题描述 投票:0回答:1

我正在为自己编写一个命令行工具来生成一个快速的html bootstrap starter,我有一个索引页,该页应该在顶部包含一个基本的导航栏,并在其底部包含一个页脚。我之前在其他项目中使用过相同的模板,并且效果很好。但是由于某种原因,它现在无法工作。所有内容都停留在页面顶部。如果我检查页面,则整个html标签的内容都在页面顶部,而页面的大部分是空白文档。这是html:

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <link rel="stylesheet" href="static/css/custom.css">
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
  <link rel="stylesheet" href="css/custom.css">
  <title>Bootstrap Starter</title>
  
  <style>
  html,
body {
  height: 100% !important;
}

.content {
  flex: 1 0 auto !important;
}
  
  </style>
</head>

<body class="d-flex flex-column">
  <!-- Navbar-->
  <nav class="navbar navbar-dark bg-dark">
    <span class="navbar-text">
        <a href="/">Bootstrap Starter</a>
      </span>
  </nav>

  <!-- Content -->
  <div class="container content"></div>

  <!-- Footer-->
  <div class="footer">
    <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/[email protected]/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>
    <!-- Footer bar-->
    <div class="p-4 mt-5 bg-light text-center"><small>© Your Name, </small></div>
  </div>
</body>

</html>

谁能告诉我为什么这不能产生理想的结果?谢谢。

html css bootstrap-4
1个回答
0
投票
您的CSS已移至文档中,现在可以使用了。这向我表明是外部样式表存在问题。我注意到您有2个自定义样式表,第3个第三方样式表之前有1个,之后的有1个。浏览器会遵守顺序,因此,如果您的代码在第一个样式表中,则第3方样式表可能会覆盖您的自定义规则。
© www.soinside.com 2019 - 2024. All rights reserved.