【问题标题】:Two full height pages using CSS flex使用 CSS flex 的两个全高页面
【发布时间】:2017-08-12 01:40:21
【问题描述】:

我想构建一个包含两个全高页面的简单网页。 这两个页面有一个居中的块和底部的小文本(带图标)。

这里是一个例子:https://jsfiddle.net/f93wm58r/

<div id="how-to" class="section how-to">
    <div id="title" class="title">title</div>
    <div id="code" class=" code">title</div>
    <div id="view-more" class="view-more">
        <span>View intructions</span>
        <br/> <!-- other option ? -->
        <i class="fa fa-arrow-down view-more--arrow"></i>
    </div>
</div>
<div id="instructions" class="section instructions">
    <div id="intructions" class="instructions">instructions</div>
    <div id="view-more" class="view-more">
        <span>Go back</span><br/>
        <i class="fa fa-arrow-up view-more--arrow"></i>
    </div>
</div>


body {
    font-family: "Source Sans Pro","Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 1.3rem;
    background-color: #FFF;
}
.section {
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    flex-flow: column wrap;
    align-content: space-between;
}
.title {
    margin-top: auto;
    font-weight: bold;
    font-size: 4rem;
}
.view-more {
    color: #D1D1D1;
    text-align: center;
    cursor: pointer;
    margin-top: auto;
    margin-bottom: 10px;
}
.view-instructions {
    margin-top: auto;
}
.view-more--arrow {
    font-size: 2rem;
}

正如您在第二页上看到的那样,文本没有居中。 我错过了什么?

额外问题

它没有响应:尝试缩小页面,内容将分两列显示

【问题讨论】:

    标签: html css flexbox single-page-application responsive


    【解决方案1】:

    您没有像使用 .title 那样为第二页标题指定 margin-topauto

    .instructions {
        margin-top: auto;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-06-25
      • 1970-01-01
      • 2016-04-30
      • 1970-01-01
      • 2018-09-16
      • 1970-01-01
      • 2014-04-14
      相关资源
      最近更新 更多