惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Schneier on Security
L
LangChain Blog
爱范儿
爱范儿
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
月光博客
月光博客
Engineering at Meta
Engineering at Meta
G
Google Developers Blog
罗磊的独立博客
阮一峰的网络日志
阮一峰的网络日志
Blog — PlanetScale
Blog — PlanetScale
宝玉的分享
宝玉的分享
GbyAI
GbyAI
T
The Exploit Database - CXSecurity.com
F
Full Disclosure
V
V2EX
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V2EX - 技术
V2EX - 技术
The Register - Security
The Register - Security
PCI Perspectives
PCI Perspectives
博客园 - 叶小钗
S
Secure Thoughts
Project Zero
Project Zero
P
Proofpoint News Feed
博客园 - 三生石上(FineUI控件)
U
Unit 42
T
Tor Project blog
美团技术团队
大猫的无限游戏
大猫的无限游戏
C
Cisco Blogs
S
Securelist
人人都是产品经理
人人都是产品经理
Cisco Talos Blog
Cisco Talos Blog
K
Kaspersky official blog
Microsoft Azure Blog
Microsoft Azure Blog
T
Threat Research - Cisco Blogs
N
News and Events Feed by Topic
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Forbes - Security
Forbes - Security
IT之家
IT之家
A
Arctic Wolf
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
腾讯CDC
TaoSecurity Blog
TaoSecurity Blog
博客园 - 【当耐特】
I
Intezer
N
News | PayPal Newsroom
Y
Y Combinator Blog
博客园_首页

博客园 - 一抹微蓝

git revert 和 git reset的区别 [JavaScript]Call和Apply方法 jQuery性能规则 把excel数据生成SQL语句 - 一抹微蓝 - 博客园 CSS长度单位及区别 em ex px pt in 一个在IE5.5,IE6,IE7,IE8都存在的BUG 同时登录多个MSN Visual Studio 2008 Service Pack 1 安装体验 VS2008常用快捷键 遍历JavaScript对象的所有属性 2、8、10、16进制的转换 推荐的 CSS 书写顺序 页面中 CSS 加载方式的优化 link 和 style 元素在 HTML 文档中的位置 Visual Studio 常用快捷键 div+css实现Firefox和IE6兼容的垂直居中 FireFox与IE开发上的一些区别 CSS兼容IE/Firefox要点 IE FireFox对CSS的不同解释收集
图片垂直居中的使用技巧
一抹微蓝 · 2008-07-04 · via 博客园 - 一抹微蓝

难点在于两点:

  1. 垂直居中;
  2. 图片是个置换元素,有些特殊的特性。

下面是一个权衡的相对结构干净,CSS简单的解决方法:

.box {
    
/*非IE的主流浏览器识别的垂直居中的方法*/
    display
: table-cell;
    vertical-align
:middle;/*设置水平居中*/
    text-align
:center;/* 针对IE的Hack */
    *display
: block;
    *font-size
: 175px;/*约为高度的0.873,200*0.873 约为175*/
    *font-family
:Arial;/*防止非utf-8引起的hack失效问题,如gbk编码*/

    width

:200px;
    height
:200px;
    border
: 1px solid #eee;
}
.box img 
{
    
/*设置图片垂直居中*/
    vertical-align
:middle;
}

<div class="box">
    <img src="http://pics.taobao.com/bao/album/promotion/taoscars_180x95_071112_sr.jpg" />
</div>