在div中将图像水平居中

本文探讨了在HTML和CSS中如何使图像在包含它的div中水平居中。尝试了多种方法,包括使用CSS Guy建议的解决方案,但实际效果不佳。问题在于顶部和底部的文本无法居中,同时图像需要在具有隐藏溢出的容器div中保持居中。讨论中提供了多个JSFiddle链接以展示不同的解决策略。
摘要由CSDN通过智能技术生成

本文翻译自:Center image horizontally within a div

This is probably a stupid question but since the usual ways of center aligning an image are not working I thought I would ask. 这可能是一个愚蠢的问题,但是由于居中对齐图像的常规方法不起作用,所以我想问一下。 How can I center align (horizontally) an image inside its container div? 如何在容器div内居中对齐(水平)图像?

Here's the HTML and CSS. 这是HTML和CSS。 I've also included the CSS for the other elements of the thumbnail. 我还包括了缩略图其他元素的CSS。 It runs in descending order so the highest element is the container of everything and the lowest is inside everything. 它以降序运行,因此最高的元素是所有内容的容器,最低的元素是所有内容的容器。

 #thumbnailwrapper { color: #2A2A2A; margin-right: 5px; 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值