html – flex-wrap导致下一行有太大的差距

参见英文答案 > Remove space (gaps) between multiple lines of flex items when they wrap1个
> How does flex-wrap work with align-self,align-items and align-content?2个
我有这个flexBox用于垂直居中两行文本.两行文字相距太远.这是我正在谈论的图像:

这是我的代码

CSS

.vertical-center {
  min-height: 100%;  /* Fallback for vh unit */
  min-height: 100vh; /* You might also want to use
                        'height' property instead.

                        Note that for percentage values of
                        'height' or 'min-height' properties,the 'height' of the parent element
                        should be specified explicitly.

                        In this case the parent of '.vertical-center'
                        is the <body> element */

  /* Make it a flex container */
  display: -webkit-Box;
  display: -moz-Box;
  display: -ms-flexBox;
  display: -webkit-flex;
  display: flex; 

  /* Align the bootstrap's container vertically */
    -webkit-Box-align : center;
  -webkit-align-items : center;
       -moz-Box-align : center;
       -ms-flex-align : center;
          align-items : center;

  /* In legacy web browsers such as Firefox 9
     we need to specify the width of the flex container */
  width: 100%;

  /* Also 'margin: 0 auto' doesn't have any effect on flex items in such web browsers
     hence the bootstrap's container won't be aligned to the center anymore.

     Therefore,we should use the following declarations to get it centered again */
         -webkit-Box-pack : center;
            -moz-Box-pack : center;
            -ms-flex-pack : center;
  -webkit-justify-content : center;
          justify-content : center;

          flex-wrap: wrap;

}

p.white,h1.white,h2.white,h3.white,h4.white,h5.white,h6.white {
    color: white;
}

.flexBox-text {
    margin: -50px,0px,-50px,0px;
}

HTML

<div class="vertical-center">
      <h1 class="text-center white flexBox-text">{{mottoText}}</h1>
      <h3 class="text-center white flexBox-text">{{mottoSubText}}</h3>
    </div>

忽略角度两种语法.如何让两行文本更接近?

解决方法

@H_502_21@ 使用flex-direction:列并从h1和h3中删除边距
.vertical-center {
  display: flex;
  flex-direction: column;
  height: 100vh;
  align-items: center;
  justify-content: center;
}

p.white,h6.white {
    color: black;
    margin: 0;
}
<div class="vertical-center">
   <h1 class="text-center white flexBox-text">THIS IS TITLE</h1>
   <h3 class="text-center white flexBox-text">SUBTITLE</h3>
</div>

相关文章

操作步骤 1、进入elasticsearch的plugin,进入ik。进入config。 2、在config下面建立以.dic为后缀的字典...
lengend data数据中若存在&#39;&#39;,则表示换行,用&#39;&#39;切割。
代码实现 option = { backgroundColor: &amp;#39;#080b30&amp;#39;, tooltip: { trigger: &...
问题原因 原因在于直接在js中取的变量并复制给var变量。 于是就变成这样。 解决办法 var data = &#...
前言 最近做了一个调查问卷导出的功能,需求是将维护的题目,答案,导出成word,参考了几种方案之后,选...
对于很多人来说,用字符编码都是熟能生巧,而不清楚为什么是那样的字符编码,所以我在这列了一个表,翻...