中心文本的图像大于容器中的文本

时间:2017-07-19 13:08:45

标签: html css twitter-bootstrap

由于某种原因,按钮粘贴在图像开始的顶部。我想把它放在容器的中间。我试图将它与中心" class:

position: relative;
top: 50%;
transform: translateY(-50%);

代码:

现在的样子:enter image description here

应该的样子:enter image description here

HTML:

<div style="background-image: url( './dist/img/background/minecraft.jpg' ); height: 125px;" class="col-md-12">

    <div class="wrapper text-center center">

        <div class="col-lg-5">

            <span style="color: #FFFFFF; font-size: 220%;">

                <img style="width: 100px; display: inline;" src="./dist/img/icon/minecraft.png" />

                Minecraftasdasdsad

            </span>

        </div>

        <div class="col-lg-3"></div>

        <div class="row">

            <div class="col-lg-4">

                <button style="color: #FFFFFF; min-width: 100px;" class="btn btn-green">

                    Start

                </button>

                <button style="margin-left: 10px; color: #FFFFFF; min-width: 100px;" class="btn btn-red">

                    Stop

                </button>

            </div>

        </div>

    </div>

</div>

1 个答案:

答案 0 :(得分:2)

这是使用flexbox的实现。

&#13;
&#13;
#center {
  display: -webkit-flex;
  display: flex;
  justify-content: flex-end;
  -webkit-align-items: center;
  align-items: center;
}
&#13;
<div style="background-image: url( 'https://cdn.pixabay.com/photo/2015/11/02/18/34/banner-1018818_960_720.jpg' ); height: 125px;" class="col-md-12">
<div class="wrapper text-center center">
  <div class="col-lg-5">
  <span style="color: #FFFFFF; font-size: 220%;">
  <img style="width: 100px; display: inline;" src="https://cdn.pixabay.com/photo/2015/11/02/18/34/banner-1018818_960_720.jpg" />
  Minecraftasdasdsad
  </span>
  </div>
  <div class="col-lg-3"></div>
  <div class="row">
    <div id="center">
      <button style="color: #FFFFFF; min-width: 100px;" class="btn btn-green">
      Start
      </button>
      <button style="margin: 10px;color: #FFFFFF; min-width: 100px;" class="btn btn-red">
      Stop
      </button>
    </div>
  </div>
  </div>
</div>
&#13;
&#13;
&#13;