如何为WordPress页面三个flex布局评价框加边框 对齐图标名称与企业logo并适配移动端
WordPress客户评价模块布局修复方案
可直接复用的完整CSS代码
替换你原有的CSS即可,HTML结构不需要修改:
/* 原有样式基础调整 */ .testimonial-outer-box { display: flex; padding: 0 15px; margin-bottom: 30px; } /* 让卡片撑满容器高度 */ .testimonial-box { width: 100%; display: flex; } .testimonial-heading { font-family: 'Playfair Display'; font-weight: bold; font-style: italic; color: #cea67e; text-align: center; font-size: 40px; padding: 20px 0 8px; } .testimonial-subheading { font-family: Roboto; text-align: center; color: #ffffff; margin-bottom: 30px; } .testimonial-block { background-color: #67213f; margin-bottom: 1.6rem; padding: 30px 15px; } /* 卡片容器调整,纵向flex布局实现底部对齐 */ .testimonial-container { border: solid 1px #cea67e; background-color: white; padding: 25px; width: 100%; display: flex; flex-direction: column; justify-content: space-between; border-radius: 4px; } /* 评价内容样式,添加开头引号装饰 */ .testimonial-title { font-size: 16px; line-height: 1.6; margin-bottom: 25px; position: relative; padding-top: 20px; } .testimonial-title::before { content: "“"; font-size: 60px; color: #cea67e; position: absolute; top: 0; left: 0; line-height: 1; } /* 企业logo统一尺寸、居中对齐 */ .testimonial-picture img { max-height: 50px; width: auto; display: block; margin: 0 auto 15px; object-fit: contain; } /* 作者、职位样式统一 */ .testimonial-author { font-weight: 600; text-align: center; margin-bottom: 5px; } .testimonial-job { text-align: center; color: #666; font-size: 14px; } /* 移动端适配 */ @media (max-width: 767px) { .testimonial-heading { font-size: 30px; } .testimonial-block { padding: 20px 10px; } }
修改说明
- 修复了原布局中卡片高度不一致的问题,通过flex纵向布局+
justify-content: space-between,保证所有卡片底部的企业logo、客户名称自动对齐 - 统一了卡片边框样式,添加了参考图中的开头引号装饰,调整了内边距让布局更美观
- 新增了移动端适配规则,小屏幕下卡片自动堆叠为单列,字体、间距自动适配手机显示
内容的提问来源于stack exchange,提问作者CodeForGood
相关产品推荐
相关产品推荐

