You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何实现文本与图片同行?网页布局问题求助

网站布局问题求助

需求与现状

  • 目标布局:两个卡片模块左右并排展示,每个卡片内部图片与文本同行排列
  • 当前问题:第二个卡片的图片错位至第一张图片下方,无法实现卡片左右并排,且卡片内文本与图片的同行布局也未达成

我的HTML代码

<body>
  <div class="main">
    <img class="logo" src="./assets/images/logo.png" alt="logo">
    <h1>We are a <span style="color: darkblue;">Creative</span> Design Agency</h1>
    <div class="left card"><img class="tile-image-left tile-image" src="./assets/images/beautiful.jpg" alt="hand and flower in water">
      <h2 class="card-title">Beauty</h2>
      <p class="card-text">We strive to create the most beautiful websites for all your needs. Working closely with you
        to
        design and
        develop an amazing website for your business.</p>
    </div>

    <div class="right card"><img class="tile-image-right tile-image" src="./assets/images/construction.jpg" alt="metal structure">
      <h2 class="card-title-right">Construction</h2>
      <p class="card-text-right">Built by our team of professional developers, we ensure the most rigourous and modern websites. Built from
        scratch using HTML and CSS. Only the best for you.</p>
    </div>

  </div>
  <footer>
    <p>Create. Develop. Design.</p>
  </footer>
</body>

我的CSS代码

body {
  font-family: "Poppins", sans-serif;
  margin: 50px 50px 0 50px;
  background-color: #faf9f6;
  display: flex;
  flex-direction: column;
  min-height: 95vh;
}
.main {
  flex: 1;
}

h1 {
  font-size: 5rem;
}

footer {
  text-align: right;
  color: midnightblue;
}

.tile-image{
  height: 200px;
}

.tile-image-left{
float: left;
clear: both;
}

尝试过的方法与困惑

我试过将div、图片和文本设置为inline-block,但没有效果;也尝试用float让文本和图片并排,结果第二个图片总是错位到第一张图片的下方。现在需要实现两个卡片左右并排布局,同时每个卡片内图片与文本同行排列,不知道该怎么解决,恳请帮助。


内容的提问来源于stack exchange,提问作者Professor Proton

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.17 13:53:07