【问题标题】:flexbox center image in middle of screen屏幕中间的flexbox中心图像
【发布时间】:2017-12-12 01:11:09
【问题描述】:

大家好,有一个简单的问题,在 bootstrap 3 中使用 flexbox,我似乎无法将我的图像放在屏幕中间,我得到了它,所以它在中间,但现在它在顶部屏幕而不是中心:

HTML:

    <div class="parallaxb">
            <div class="homeimgbarber">
            <img class="img-responsive" src="img/cuts.png" style="margin: auto;">
              </div>
  </div>

CSS:

.parallax {
    background-image: url("../img/c.png");
    min-height: 1000px;
    background-attachment: fixed;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
}

.homeimgbarber {
    display: flex;
    justify-content: center;
    align-items: center;
}

【问题讨论】:

    标签: html twitter-bootstrap css


    【解决方案1】:

    这是因为 .homeimgbarber 需要应用高度。

    .parallax {
        background-image: url("http://via.placeholder.com/350x150");
        height: 1000px;
        background-position: center;
        background-repeat: no-repeat;
        background-size: cover;
    }
    
    .homeimgbarber {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100vh;
    }
       <div class="parallaxb">
                <div class="homeimgbarber">
                <img class="img-responsive" src="http://via.placeholder.com/350x150">
                  </div>
      </div>

    【讨论】:

    • 随时!不要忘记接受这个答案:) 快乐编码
    猜你喜欢
    • 2017-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-20
    • 2013-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多