【问题标题】:Bootstrap columns not same height in iPad portrait modeiPad纵向模式下的引导列高度不同
【发布时间】:2017-08-23 17:20:33
【问题描述】:

所以我正在制作的这个网站的肖像模式全都搞砸了。目前看起来像这样:

我想要的只是让手表垂直居中,这是在普通桌面视图中。

HTML:

<header>
    <div class="container">
        <div class="row">
          <div class="col-sm-7 col-md-7  col-xl-7 col-lg-7">
              <div class="header-content">
                  <div class="header-content-inner">
                      <h1>One for all. All for you.</h1>
                      <!-- <a href="#download" class="btn btn-outline btn-xl page-scroll">Start Now for Free!</a> -->
                  </div>
              </div>
          </div>
          <div class="col-sm-5 col-md-5  col-xl-5 col-lg-5" style="height: 100%">
            <div class="device-container vertical-align">
              <div class="cycle-slideshow" data-cycle-timeout="1500" data-cycle-transition="1500" data-cycle-fx="fadeout" data-cycle-pause-on-hover="#er-pauser">
                <img class="img-responsive device-img center-block" src="img/landing2.png" alt="">
                <img class="img-responsive device-img center-block" src="img/landing1.png" alt="">
                <img class="img-responsive device-img center-block" src="img/landing3.png" alt="">
                <img class="img-responsive device-img center-block" src="img/landing5.png" alt="">
                <img class="img-responsive device-img center-block" src="img/landing4.png" alt="">
                <img class="img-responsive device-img center-block" src="img/landing6.png" alt="">
              </div>
            </div>
          </div>
        </div>
    </div>
    </header>

CSS:

header {
        position: relative;
        width: 100%;
        min-height: auto;
        overflow-y: hidden;
        background: #47c0d7; /* Old browsers */
        background: -moz-linear-gradient(top, #47c0d7 0%, #e6f9ff 55%, #e6f9ff 100%); /* FF3.6-15 */
        background: -webkit-linear-gradient(top, #47c0d7 0%,#e6f9ff 55%,#e6f9ff 100%); /* Chrome10-25,Safari5.1-6 */
        background: linear-gradient(to bottom, #47c0d7 0%,#e6f9ff 55%,#e6f9ff 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
        filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#47c0d7', endColorstr='#e6f9ff',GradientType=0 ); /* IE6-9 */

    }
    header .header-content {
      text-align: center;
      padding: 100px 0px 0px;
      position: relative;

    }
    header .header-content .header-content-inner {
      width:100%;
      text-align: center;
      position: relative;
    /*  max-width: 500px;
    */  margin: 0 auto;
    }

    header .device-container {
    /*  max-width: 400px;*/
      height: 100%;
    /*  margin: 100px auto;
    */}

    header .device-img {
      left: 0;
      right: 0;
      width: 100%;
      margin: 0 auto;
      width: 300px;
    }

    @media (min-width: 768px) {
        header {
        min-height: 100%;
      }

      header .header-content {
        text-align: center;
        padding: 0;
        height: 100vh;
      }
      header .header-content .header-content-inner {
        text-align: center;
        max-width: none;
        margin: 0 auto;
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        width: 100%;
      }

    .about-content .about-content-inner {
        text-align: justify;
        max-width: none;
        position: relative;
        top: 50%;
        transform: translateY(-50%);
      }
      header .header-content .header-content-inner h1 {
        margin-top: 0;
        margin-bottom: 30px;
        font-size: 55px;
        color: #363939;
        text-align: center;
      }
    .about-content .about-content-inner h3 {
        font-size: 20px;
        font-weight: 400;
      }
      header .device-container {
     /*   max-width: none;
        max-height: calc(0vh);
        margin: 100px auto 0;*/
        padding: 0;
        height: 100vh;
      }

它所在的列的高度不是 100%,它所在的容器(设备容器)似乎也没有容纳它的内容。

非常感谢您的帮助。抱歉有这么多评论出来的东西。另外,如果有人知道为什么导航栏会延伸到页面之外,从而使右侧的浅蓝色列发生,请也告诉我。

【问题讨论】:

  • 手表在桌面视图中没有垂直居中。您能否在BootPly 之类的东西上创建一个minimal, complete, and verifiable example,它同时显示所需的视图和不希望的视图?我感觉问题出在第 114 行,您在 .device-container.device-container 上设置了 heightheight 768px,但无法确定不能重新创建问题。

标签: html ios css twitter-bootstrap ipad


【解决方案1】:

如您所料,在浮动框上设置100% 不会使其达到父高度的100%。在我看来,您最好的解决方案是使用

header .row {
  display: flex;
  align-items: center;
  min-height: 100vh;
}

当然,这意味着您需要丢失&lt;h1&gt; 上的巨大顶部填充,因此它实际上是居中的。如果您对它在桌面上的外观感到满意,只需将我的建议包含在 @media 查询中即可。

我还要注意一件事:您似乎使用了 col-xl-* 类,这些类在 Bootstrap 中不存在,但您似乎错过了 col-xs-* 类。这是故意的吗?如果没有,请更换它们。

这是一个fiddle,我可以从你发布的代码中得到什么。

别忘了autoprefix

【讨论】:

  • 是的,是我的 display/align-items 搞砸了媒体查询 768 谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-12-29
  • 2013-01-22
  • 1970-01-01
  • 2012-10-13
  • 1970-01-01
  • 2023-04-09
相关资源
最近更新 更多