未知长宽元素在已知300px*300px的容器中垂直居(IE6/7/8/FF)

上次电话面试没答出来,今天重新记录一下。FF下的确难搞...郁闷

加了很多HACK,顺便复习一下!

*+property:value; /* IE7 */ 
_property
:value; /* IE6 */ 

*property:value; /*IE6、IE7 共用*/ 

 

<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< html  xmlns ="http://www.w3.org/1999/xhtml" >
< head >
< meta  http-equiv ="Content-Type"  content ="text/html; charset=utf-8"   />
< title > IE6/7/8/FF垂直居中 </ title >
< style >
{  margin : 0 ;  padding : 0 ;   }
#out 
{  display : table ;  background-color : #F00 ;  width : 300px ;  height : 300px ;  _position : relative ;  overflow : hidden ;   }
#mid 
{  vertical-align : middle ;  display : table-cell ;  _position : absolute ;  _top : 50% ;  -left : 50% ;   }
#in 
{  _position : relative ;  _top : -50% ;  _left : -50% ;  text-align :  center ;   }
*+html #out 
{  background-color : #F00 ;  width : 300px ;  height : 300px ;  position : relative ;  overflow : hidden ;   }
*+html #mid 
{   position : absolute ;  top : 50% ;  left : 50% ;   }
*+html #in 
{  position : relative ;  top : -50% ;  left : -50% ;   }
</ style >
</ head >
< body >
< div  class ="container" >
< div  id ="out" >
    
< div  id ="mid" >
        
< div  id ="in" >  FF垂直居中FF直居中 < br  />
            FF垂直居中F直居中
< br  />
            FF垂直居中F直居中
< br  />
            FF垂直居中F直居中
< br  />
        
</ div >
    
</ div >
</ div >
</ body >
</ html >

 

转载于:https://www.cnblogs.com/cnfiowen/archive/2009/10/29/1592624.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值