html - 如图所示,创建两个响应式 DIV,它们之间留有空间

标签 html css responsive-design mobile-website

To further understand my demand, click on this link and look at the image.

我正在参加 Codewell 挑战,但我陷入了这部分。我无法在它们之间留出均匀的空间,并且图像重叠。

.website {
  display: flex;
  justify-content: space-between;
}

.arrow {
  display: inline-block;
  width: 1rem;
}
<div class="website">
  <div class="spense">
    <img id="spense" src="./Assets/Spense.png" alt="spense">
    <h3>Spense.com<img class="arrow" src="./Assets/noun-arrow-2841221-svg.png" alt="arrow-icon"></h3>
    Rethinking the way writers get paid, an open resource platform <br> design to help writers focus more on writing, and less on <br> when and how they'll get paid, Projects in collaboration with <br> Codewell.cc
  </div>
  <div class="yelp">
    <img id="yelp" src="./Assets/YelpCamp.png" alt="YelpCamp">
    <h3>YelpCamp.com<img class="arrow" src="./Assets/noun-arrow-2841221-svg.png" alt="arrow-icon"></h3>
    Allowing backpack travelers to perfectly plan their trip <br> through an open-source platform similar to TripAdvisor. With <br>over 1m MAU, YelpCamp has been the crowd's favorite in <br>2021.
  </div>
</div>

最佳答案

您可以在 Flex 容器内的每个子项上使用宽度属性。

.website {
  display: flex;
  justify-content: space-between;
}

.spense, .yelp{
  width:40%;
}
.arrow {
  display: inline-block;
  width: 1rem;
}
.image{
width:100%;
object-fit:cover;
}
<div class="website">
  <div class="spense">
    <img class="image" id="spense" src="https://via.placeholder.com/350

C/O https://placeholder.com/" alt="spense">
    <h3>Spense.com<img class="arrow" src="./Assets/noun-arrow-2841221-svg.png" alt="arrow-icon"></h3>
    Rethinking the way writers get paid, an open resource platform <br> design to help writers focus more on writing, and less on <br> when and how they'll get paid, Projects in collaboration with <br> Codewell.cc
  </div>
  <div class="yelp">
    <img class="image" id="yelp" src="https://via.placeholder.com/350

C/O https://placeholder.com/" alt="YelpCamp">
    <h3>YelpCamp.com<img class="arrow" src="./Assets/noun-arrow-2841221-svg.png" alt="arrow-icon"></h3>
    Allowing backpack travelers to perfectly plan their trip <br> through an open-source platform similar to TripAdvisor. With <br>over 1m MAU, YelpCamp has been the crowd's favorite in <br>2021.
  </div>

关于html - 如图所示,创建两个响应式 DIV,它们之间留有空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71045875/

相关文章:

html - 更改背景图像的默认大小

html - 最大宽度应该覆盖宽度,但不是

html - 将高度设置为 100vh 时,页面在垂直方向上显示为屏幕大小的两倍以上

javascript - 让 div 填满一个包含的 div?

html - 需要两列堆叠而不是重叠移动

html - 将 http 请求 header 添加到 href 链接

javascript - 将选择值发送到 JS 函数

jquery - IE6 和 html <select> 元素的 Z-Index 问题

html - 如何创建响应式表格列

css - 用于创建移动版本的媒体查询和 "display: none"