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

移动端如何让图片显示在文字下方并实现文字左对齐

解决方案

添加移动端响应式媒体查询覆盖桌面端布局规则即可实现需求,适配代码如下:

/* 移动端断点可根据项目实际需求调整,常用值为576px/768px */
@media (max-width: 767px) {
  /* 解决文字偏右问题:重置桌面端预设的左侧边距 */
  .left-200 {
    margin-left: 0;
    padding-left: 0;
    /* 若原布局使用Flex实现图文并排,添加以下两行规则 */
    display: flex;
    flex-direction: column;
  }
  /* 强制文字左对齐,避免继承其他对齐规则 */
  .left-200 h3, 
  .left-200 p {
    text-align: left;
  }
  /* 解决图片位置问题:调整图片顺序与适配尺寸 */
  .left-200 .image {
    width: 100%;
    height: auto;
    margin-top: 10px;
    /* 若Flex布局下图文顺序不对,可通过order属性强制调整 */
    order: 2;
  }
  .left-200 > div:first-of-type {
    order: 1;
  }
}

如果原桌面端是使用float属性实现图文并排布局,使用以下适配代码即可:

@media (max-width: 767px) {
  .left-200 {
    margin-left: 0;
    padding-left: 0;
  }
  .left-200 h3, 
  .left-200 p {
    text-align: left;
  }
  .left-200 .image {
    float: none;
    clear: both;
    width: 100%;
    height: auto;
    margin-top: 10px;
  }
}

内容的提问来源于stack exchange,提问作者Waffle Boots

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.26 18:54:01