html - flex-items 空间没有在小屏幕上分配

标签 html css flexbox

我试图添加 justify-content: space-between; 以便两个 flex 元素之间有相等的空间。

我正在尝试使用 justify-content: space-between;

分配空间

有什么想法吗?

/* SECTION THREE */
.sec-3 {
  background-color: #f1eeee;
  margin-top: -22px;
}

.sec-3-flex {
  background-color: red;
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  justify-content: space-around;
}

.sec-3-flex #iphone-2-img {
  padding-top: 30px;
  background-color: orange;
  margin-right: -10%;
}

.sec-3-flex .sales-copy-wrap {
  background-color: yellow;
}

#iphone-sec-3 {}
<div class="sec-3">
  <!-- iphone image  -->
  <div class="sec-3-flex">
    <!-- Iphone 1 image -->
    <picture id="iphone-sec-3">
      <!-- <source media="(min-width: 320px)" srcset="img/mobile/mobile-iphone-1.jpg"> -->
      <source media="(min-width: 320px)" srcset="img/desktop/images/home_11.jpg">
      <img id="iphone-2-img" src="img_orange_flowers.jpg" alt="Flowers" style="width:50%">
    </picture>
    <div class="sales-copy-wrap">
      <h3>Get organized with events, tasks and notes.</h3>
      <p class="sales-copy">Now more then ever it is critical for smart professionals to stay up to date with important deadlines.</p>
    </div>
  </div>
</div>

最佳答案

图像不是 flex 元素。它是 flex 元素 (picture) 的子项。

因此在这个 flex 元素中,图像(自然地)向左对齐。

将此添加到您的代码中:

picture {
   text-align: right;
}

关于html - flex-items 空间没有在小屏幕上分配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45094132/

相关文章:

html - 开始我的第一个元素(寻找批评、一般提示、仇恨)

html - Flexbox 2 div 不同的高度

javascript - Jquery向所有输入字段添加 data-rel 属性并删除 name 属性

javascript - IE9 悬停错误 - 移动一行后悬停状态保持不变

CSS - IE 中的渐变

jquery - jcrop css 更新 vline 和 hline

css - vaadin 对菜单内的 div 应用 css-classname

css - 如何使包装的 flexbox 的内容均匀增长?

php - CI 中的多个选择语句

html - 仅在元素的一侧添加框阴影模糊