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

推荐订阅源

Google DeepMind News
Google DeepMind News
Stack Overflow Blog
Stack Overflow Blog
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
T
The Blog of Author Tim Ferriss
博客园 - 叶小钗
N
Netflix TechBlog - Medium
腾讯CDC
C
Check Point Blog
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
S
SegmentFault 最新的问题
F
Fortinet All Blogs
美团技术团队
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 司徒正美
F
Full Disclosure
Recorded Future
Recorded Future
D
DataBreaches.Net
博客园 - 【当耐特】
Martin Fowler
Martin Fowler
J
Java Code Geeks
I
InfoQ
Y
Y Combinator Blog
A
About on SuperTechFans
AI
AI
爱范儿
爱范儿
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Forbes - Security
Forbes - Security
W
WeLiveSecurity
M
MIT News - Artificial intelligence
雷峰网
雷峰网
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
Schneier on Security
Schneier on Security
The GitHub Blog
The GitHub Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
GRAHAM CLULEY
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Docker
Recent Commits to openclaw:main
Recent Commits to openclaw:main
量子位
V2EX - 技术
V2EX - 技术
Project Zero
Project Zero

博客园 - 骑着夕阳看着猪

asp.net mvc 中hmtl.xxxx是否使用<%=... %> 高版本(vs2008)如何打开低版本解决方案和项目(vs2003、vs2005的项目) 序列化和反序列化 sql 根据父节点查找所有子节点 用jquery实现学校的校历 一步一步学jquery UI 1.72 之datepicker - 骑着夕阳看着猪 显示日期是当前区间第几周? - 骑着夕阳看着猪 - 博客园 c# 日期相减 实现qq邮箱换肤(第二季 ) - 骑着夕阳看着猪 - 博客园 实现qq邮箱换肤(第一季 ) 获取元素和鼠标的位置(兼容IE6.0,IE7.0,IE8.0,FireFox2.0,FireFox3.5,Opera) img src='' 为空引发的问题 - 骑着夕阳看着猪 如何清除html图片缓存 - 骑着夕阳看着猪 - 博客园 关于 wcf揭秘 第四章代码运行错误 - 骑着夕阳看着猪 配置SQL Server2005以允许远程访问 SQL Server2005还原数据库详细 初试ajax基础 实现控件的随意拖动 BindingManagerBase的应用
如何使图片在div里上下居中 - 骑着夕阳看着猪 - 博客园
骑着夕阳看着猪 · 2009-12-21 · via 博客园 - 骑着夕阳看着猪

代码

<style type="text/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;
         
         width
:100px;
         height
:100px;
        
}
        .box img {
         
/*设置图片垂直居中*/
         vertical-align
:middle;
         cursor
:pointer;
        
}
        </style>

Dom元素:

代码

                  <div id="div1"  class="box">
                     
<img src="xxx.png" /><br />风华绝代

                  </div>

 这种方式在ie8和firefox3.5中显示正确,在ie7及以下版本无法正确显示,其它浏览器没有测试。因此改成了下面的方式:

代码

         .box{
         float
:left;
         width
:80px;
         height
:80px;
         border
: 1px solid #eee;
        
}

        .selected 

{
            border
:solid 1px black;
            background-color
:Aqua;
            cursor
:pointer;
        
}
        .box img 
{
         
/*设置图片垂直居中*/
         vertical-align
:middle;
         cursor
:pointer;
        
}