添加边框时空白消失

时间:2019-04-20 16:28:27

标签: html css bootstrap-4

这是我第二次遇到此问题。 该代码使用Bootstrap。 div或nav / div之间有一个神秘的空格。在开发工具中选中后,该元素未显示为任何元素的空白。

CSS 1(这会导致导航栏和div之间出现空白,即使按照我搜索的答案所建议的那样从下至下也要重新设置边距)。

.navbar,
.navbar-inverse {
  margin-bottom: 0px !important;
}

.intro {
  height: 100vh;
  width: 100vw;
  background: #FF0066;
}
<!DOCTYPE html>
<html>

<head>
  <title>Processing</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
  <link rel="stylesheet" href="style.css" type="text/css">
</head>

<body>
  <nav class="navbar navbar-inverse">
    <div class="container-fluid">
      <div class="navbar-header">
        <a class="navbar-brand" href="#">PROCESSOR</a>
      </div>
      <ul class="nav navbar-nav">
        <li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">Processing <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#">to EXCEL</a></li>
            <li><a href="#">Combining</a></li>
            <li><a href="#">Sheets</a></li>
          </ul>
        </li>
        <li><a href="#">About</a></li>
        <li><a href="#">Developers</a></li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="#"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
        <li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
      </ul>
    </div>
  </nav>
  <div class="intro">
    <h1>PROCESSOR</h1>
    <p>Process your raw files to a readable files.</p>
  </div>
</body>

</html>

CSS 2(空格已在此处删除。这不只是先前分隔的div的边框吗?)

.navbar,
.navbar-inverse {
  margin-bottom: 0px !important;
}

.intro {
  height: 100vh;
  width: 100vw;
  background: #FF0066;
  border: 2px solid black;
}
<!DOCTYPE html>
<html>

<head>
  <title>Processing</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
  <link rel="stylesheet" href="style.css" type="text/css">
</head>

<body>
  <nav class="navbar navbar-inverse">
    <div class="container-fluid">
      <div class="navbar-header">
        <a class="navbar-brand" href="#">PROCESSOR</a>
      </div>
      <ul class="nav navbar-nav">
        <li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">Processing <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#">to EXCEL</a></li>
            <li><a href="#">Combining</a></li>
            <li><a href="#">Sheets</a></li>
          </ul>
        </li>
        <li><a href="#">About</a></li>
        <li><a href="#">Developers</a></li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="#"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
        <li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
      </ul>
    </div>
  </nav>
  <div class="intro">
    <h1>PROCESSOR</h1>
    <p>Process your raw files to a readable files.</p>
  </div>
</body>

</html>

它的原因是什么?修复了哪些问题?

0 个答案:

没有答案