Html 为什么垂直定心后,我的div顶部会有额外的间距?

Html 为什么垂直定心后,我的div顶部会有额外的间距?,html,css,Html,Css,我一直在使用垂直间距技巧来处理所有包含文本的div,虽然它使垂直间距从0%到90%完全居中,但它在顶端留下了比底部更多的空间。它在我用过的每一个div上都有。我已尝试将padding/margin设置为0,但什么也没发生。不确定具体是什么导致了这种情况。真让人恼火。有人有主意吗 实例- 问题图片- HTML- <section id="about" ng-controller="aboutController"> <div class="container-fl

我一直在使用垂直间距技巧来处理所有包含文本的div,虽然它使垂直间距从0%到90%完全居中,但它在顶端留下了比底部更多的空间。它在我用过的每一个div上都有。我已尝试将padding/margin设置为0,但什么也没发生。不确定具体是什么导致了这种情况。真让人恼火。有人有主意吗

实例-

问题图片-

HTML-

<section id="about" ng-controller="aboutController">    
  <div class="container-fluid">

    <div class="row about-row">

      <div class="about-left col-xs-12 col-md-6">
      </div>

      <div class="about-right col-xs-12 col-md-6">
        <div class="about-content">
          <div class="about-content-title">
            <h1><strong>I'M JAY.</strong></h1>
          </div>

          <div class="about-content-info">
            <p ng-if="about.firstParagraph">{{ about.paragraphOne }}</p>
            <p ng-if="!about.firstParagraph">{{ about.paragraphTwo }}</p>
          </div>

          <div class="about-button">
            <button ng-if="about.firstParagraph" class="label label-success" ng-click="about.switchParagraph()">MORE =></button>
            <button ng-if="!about.firstParagraph" class="label label-success"><a href="##skills">VIEW SKILLS</a></button>
          </div>

          <div class="about-personal-info">
            <h4>Email: jaybittner@gmail.com</h4>
          </div>

          <div class="about-icon">
            <a href="{{ profile.url }}" ng-repeat="profile in about.profiles"><img ng-src="{{ profile.icon }}" /></a>
          </div>
        </div>

      </div>

    </div>

  </div>
</section>

尝试将
*{margin:0px;padding:0px;}
添加到样式表中,然后从中编辑div标记。祝你好运。

你可以在另一个div的垂直中心使用css技巧:

#outerdiv{
宽度:700px;
左边距:自动;
右边距:自动;
高度:400px;
位置:相对位置;
背景:#eee;
文本对齐:居中;
}
#innerdiv{
宽度:240px;
高度:100px;
位置:绝对位置;
最高:50%;
左:50%;
左边距:-120px;/*innerdiv宽度的一半*/
页边距顶部:-50px;/*innerdiv高度的一半*/
背景:#ccc;
}

居中div

答案是,我需要在.about内容标题h1中添加“页边空白顶部:0”。h1上方有一个额外的空格,这导致content div在其顶部有额外的空格。div居中,但内部有空白。这把它修好了

.about-content-title h1 {
  font-size: 3.1vw;
  margin-bottom: 0.6vh;
  margin-top: 0;
}

JSFIDLE或live example?提供呈现的HTML@JoostAnswer结果是,我必须从每个页面的所有h1中删除“margin top”。上面多余的空间破坏了外观。解释什么,如何,为什么?这让你的答案对其他人很清楚。
.about-content-title h1 {
  font-size: 3.1vw;
  margin-bottom: 0.6vh;
  margin-top: 0;
}