没有不值得去解决的问题,也没有不值得去学习的技术!

图片水平垂直居中的CSS解决方案!

作者:

html:

<ul>
<li>
<div><a href=”#” target=”_blank”><img src=”images/brand/product/1.png” width=”142″ height=”158″ alt=”产品名称一”></a></div>
<span><a href=”#” target=”_blank”>海星鱼缸水族箱&nbsp;&nbsp;AEC&nbsp;&nbsp;单拱面&nbsp;&nbsp;拱面鱼缸</a></span>
<span>免换水&nbsp;&nbsp;全国包邮&nbsp;&nbsp;生态鱼缸</span>
<div><a href=”#” target=”_blank”>查看详情</a></div>
</li>
<li>
<div><a href=”#” target=”_blank”><img src=”images/brand/product/2.png” width=”167″ height=”161″ alt=”产品名称二”></a></div>
<span><a href=”#” target=”_blank”>海星鱼缸水族箱&nbsp;&nbsp;AEC&nbsp;&nbsp;单拱面&nbsp;&nbsp;拱面鱼缸</a></span>
<span>免换水&nbsp;&nbsp;全国包邮&nbsp;&nbsp;生态鱼缸</span>
<div><a href=”#” target=”_blank”>查看详情</a></div>
</li>
<li>
<div><a href=”#” target=”_blank”><img src=”images/brand/product/3.png” width=”139″ height=”161″ alt=”产品名称三”></a></div>
<span><a href=”#” target=”_blank”>海星鱼缸水族箱&nbsp;&nbsp;AEC&nbsp;&nbsp;单拱面&nbsp;&nbsp;拱面鱼缸</a></span>
<span>免换水&nbsp;&nbsp;全国包邮&nbsp;&nbsp;生态鱼缸</span>
<div><a href=”#” target=”_blank”>查看详情</a></div>
</li>
<li>
<div><a href=”#” target=”_blank”><img src=”images/brand/product/4.png” width=”138″ height=”161″ alt=”产品名称四”></a></div>
<span><a href=”#” target=”_blank”>海星鱼缸水族箱&nbsp;&nbsp;AEC&nbsp;&nbsp;单拱面&nbsp;&nbsp;拱面鱼缸</a></span>
<span>免换水&nbsp;&nbsp;全国包邮&nbsp;&nbsp;生态鱼缸</span>
<div><a href=”#” target=”_blank”>查看详情</a></div>
</li>
</ul>

 

css:

.brand_list .pro_list {
float: left;
width: 984px;
overflow: hidden;
}
.pro_list li {
display: block;
float: left;
height: 300px;
width: 210px;
margin-right: 16px;
overflow: hidden;
padding: 0 10px;
text-align: center;
}
.pro_list .thumb {
height: 200px;
width: 200px;
overflow: hidden;
position: relative;
display: table-cell;
text-align: center;
vertical-align: middle;
padding: 5px;
}
.pro_list .thumb a {
display: block;
position: static;
*position: absolute;
top: 50%;
}
.pro_list .thumb img {
position: static;
*position: relative;
top: -50%;
left: -50%;
}

 

 

css:在IE6的垂直居中有一点小的问题,就是并未绝对的垂直居中,只是近似罢了,但是在其它浏览器中却是没有问题的哈。

需要长期技术维护或远程问题排查?

我是拥有 15+ 年经验的 PHP / Go 后端工程师,长期关注已有系统维护、Bug 修复、性能优化、服务器排查、WordPress 网站维护和小功能迭代。

如果你的项目遇到以下情况,可以先从一次小问题排查开始合作:

  • ✅ PHP / Laravel / Yii2 老项目无人维护
  • ✅ Go / Gin 后端接口需要排查或优化
  • ✅ WordPress 网站访问慢、报错或插件冲突
  • ✅ Nginx / MySQL / Redis / Linux 服务器异常
  • ✅ CDN / Cloudflare / DNS / HTTPS 配置问题
  • ✅ 需要长期远程技术支持或兼职维护

更多介绍请查看:关于我 & 合作

微信:13980074657
邮箱:shuijingwanwq@gmail.com
Telegram:@shuijingwan
GitHub:https://github.com/shuijingwan

评论

2 条对“图片水平垂直居中的CSS解决方案!”的回复

  1. conscience 的头像

    Hey very nice website!! Guy .. Excellent .. Wonderful .. I will bookmark your site and take the feeds alsoI am|I’m} glad to seek out so many useful info right here in the submit, we’d like work out more techniques in this regard, thank you for sharing. . . . . .

  2. occurrence 的头像

    Thanks for sharing excellent informations. Your web-site is very cool. I am impressed by the details that you have on this blog. It reveals how nicely you perceive this subject. Bookmarked this website page, will come back for more articles. You, my pal, ROCK! I found just the information I already searched all over the place and simply could not come across. What a great site.

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理