【问题标题】:Flexbox with unexpected whitespace at top顶部带有意外空白的 Flexbox
【发布时间】:2017-10-01 16:01:15
【问题描述】:

我的 flexbox 无法一直填充到我的导航栏时遇到问题,我终其一生都无法弄清楚,负边距完全没有任何作用

这是截图

.hero {
  background-image: url("https://unsplash.it/1500?random");
  background-size: cover;
  background-position: center;
  width: 100%;
  height: 100%;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  margin-top: -10px;
}

.hero>.center-content {
  width: 400px;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  margin: auto;
}

.hero>.center-content h1,
.center-content h3 {
  color: white;
  line-height: 1;
}

.hero>.center-content h1 {
  text-transform: uppercase;
  font-size: 3em;
  margin-bottom: 0;
  text-align: center;
}

.hero>.center-content h3 {
  margin-bottom: 40px;
  font-size: 1.5em;
  font-weight: normal;
}

.center-content>.button {
  text-transform: uppercase;
  color: white;
  padding: 20px;
  border: 1px solid white;
  text-decoration: none;
}

.center-content>.button:hover {
  background-color: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.7);
  color: #006594;
}
<div class="container" id="heroImage">
  <div class="hero">
    <div class="center-content">
      <h1>Lazris</h1>
      <h3>Revive Your Web Presence</h3>
      <a href="#" class="button">Some Action Here</a>
    </div>
  </div>
</div>

【问题讨论】:

  • 您没有提供导航栏的代码,所以目前没有空格!

标签: html css flexbox


【解决方案1】:

删除活动菜单上的顶部边距

.nav > .active {
    /** margin-top: 10px; Remove **/
}

【讨论】:

  • 问题中的规则.nav &gt; .active { 在哪里可用?
  • 这意味着,当该链接失效时,这个答案和问题对于未来的用户来说都是无用的,因为导致它的问题将永远无法再访问。这是回答问题的一种非常糟糕的方式,所以我投了反对票。如果 OP 更新了问题,所以这个答案是有意义的,请通知我,我会收回我的反对票
猜你喜欢
  • 1970-01-01
  • 2012-12-03
  • 1970-01-01
  • 2013-11-30
  • 2020-12-17
  • 2013-09-17
  • 1970-01-01
  • 1970-01-01
  • 2017-09-27
相关资源
最近更新 更多