html - 填充顶部不起作用

标签 html css twitter-bootstrap

我正在尝试将我的“Sanchez Designs……Ms Sanchez……”和“Web Developer, Artist and Higher Education”按钮放在页面中间,就在山顶。我已经研究并尝试过但无法移动它。我认为 padding-top 可以解决问题,但没有。有什么建议吗?

此外,我正在学习网络开发,所以请保持温柔。谢谢!

  body {
  background-image: url('images/background3.jpeg');
  width: 100%;
  height: 100%;
  background-position: top center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: cover;
  background-color: #464646;
  font-family: 'Lato', sans-serif;
  color: white;
}

@media only screen and (max-width: 767px) {
  body {
    background-image: url('images/background3.jpeg');
  }
<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <link rel="stylesheet" href="http://path/to/font-awesome/css/font-awesome.min.css">
  <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
  <link rel="stylesheet" href="Sanchez_Bootstrap_index.css">
  </style>
  <title>Sanchez</title>
</head>

<body>

  <!--NAVBAR-->
  <nav class="navbar navbar-expand-sm navbar-dark bg-dark">
    <div class="container">
      <a class="navbar-brand" href="">Andrea Designs</a>

      <!--Toggle Button-->
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span></button>

      <!--Navbar links-->
      <div class="collapse navbar-collapse" id="navbarResponsive">
        <ul class="navbar-nav ml-auto">
          <li class="nav-item">
            <li class="nav-item">
              <a class="nav-link" href="Sanchez_bootstrap_about.html">About</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="Sanchez_bootstrap_artist.html">Artist</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="Sanchez_bootstrap_highered.html">Higher Education</a>
            </li>
        </ul>
      </div>
    </div>
  </nav>
  <div class="container">
    <div class="row">
      <div class="col-lg-12 text-center">
        <div id="content">
          <h1> Sanchez Designs</h1>
          <h5> Ms. Sanchez is an aspiring Web Developer</h5>
          <hr>
          <ul class="list-inline intro-social-buttons">
            <li class="list-inline-item">
              <a href="Sanchez_Bootstrap_about.html" class="btn btn-dark btn-lg">
                <span class="network-name">Web Developer</span></a>
            </li>

            <li class="list-inline-item">
              <a href="Sanchez_Bootstrap_artist.html" class="btn btn-dark btn-lg">
                <span class="network-name">Artist</span></a>
            </li>

            <li class="list-inline-item">
              <a href="Sanchez_Bootstrap_highered.html" class="btn btn-dark btn-lg">
                <span class="network-name">Higher Education</span></a>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </div>

  </header>
  <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
</body>

</html>

Example

最佳答案

如果你想填充顶部尝试 padding-top : 20px!important

如果您想在中心进行 div 测试,为什么要尝试填充顶部或底部。您可以使用额外的 div 并赋予样式 display: flex;对齐元素:居中;

.banner {
    height: 80vh;
    align-items: center;
    vertical-align: middle;
    display: flex;
}

喜欢:https://www.w3schools.com/code/tryit.asp?filename=FNBF6UP5MV4S

关于html - 填充顶部不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48179361/

相关文章:

php - 将表单发送到 SQLdatabase(不允许 405)

c# - 使用计数器属性时如何将页码放在底部

Java/HTML - 抛出 InvokingTargetException

javascript - 带有下拉菜单的输入组按钮在 Bootstrap 中不起作用

jquery - 在 Bootstrap 4 中调整导航栏

html - 简单的边框颜色不适用于 IE7

php - 如何使用 CSS 中的显示属性显示文本

javascript - 如何使我的选择框与 Bootstrap 2.1.1 中其他文本元素的大小相匹配?

css - Angular Material 垫网格瓷砖高度

javascript - 如何用bootstrap容器类实现小技巧?