相关疑难解决方法(0)

防止弹性项目从一侧到另一侧呈现

我正在使用flexbox将一些项目放在一个块中,但我希望每个项目都在它自己的行中.例如,我希望橙色方块位于文本上方,但是在使用flex之后它将它移动到文本的一侧 - 有没有人知道这方面的方法呢?

.container {
  height: 200px;
  width: 200px;
  background: cornflowerblue;
  position: relative;
}

.inner {
  height: 100%;
  position: absolute;
  left: 0;
  width: 100%;
  top: 0;
  display: -webkit-box;
  display: -moz-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
  align-items: center;
  justify-content: center;
}

.square {
  width: 30px;
  height: 30px;
  background: tomato;
  display: block;
}
Run Code Online (Sandbox Code Playgroud)
<div class="container">
  <div class="inner">
    <div class="square"></div>

    <p>some text</p>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

html css css3 flexbox

7
推荐指数
2
解决办法
2346
查看次数

标签 统计

css ×1

css3 ×1

flexbox ×1

html ×1