• [织梦吧]唯一域名:www.dedecms8.com,织梦DedeCMS学习平台.

当前位置: > 网页制作 > DIV+CSS特效 >

图片水平居中兼容IE6、7、8和FF

来源: www.dedecms8.com 编辑:织梦吧 时间:2012-02-06点击: 次
   

  1. 		<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  2. <html xmlns="http://www.w3.org/1999/xhtml"> 
  3. <head> 
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
  5. <title>图片等比缩放及水平居中兼容各种浏览器</title> 
  6. <style type="text/css"> 
  7. .box { 
  8.     display: table-cell; 
  9.     vertical-align:middle; 
  10.     text-align:center; 
  11.     *display: block; 
  12.     *font-size: 175px;  /*高度/字体大小的比值为1.14*/ 
  13.     *font-family:Arial; 
  14.     width:200px; 
  15.     height:200px; 
  16.     border: 1px solid #ccc; 
  17.     padding:3px; 
  18.     overflow:hidden; /*防止用js缩放时出现不及时*/ 
  19. } 
  20. .box img{ 
  21.     vertical-align:middle; border:0; 
  22. } 
  23. </style> 
  24. <script language="javascript"> 
  25. var flag=false; 
  26. function DrawImage(ImgD,w,h){ 
  27.     var image=new Image(); 
  28.     image.src=ImgD.src; 
  29.     if(image.width>0 && image.height>0){ 
  30.         flag=true; 
  31.         if(image.width/image.height>= w/h){ 
  32.             if(image.width>w){ 
标签: 图片 水平 居中
猜你也喜欢看这些...

热门TagS

About D8

  • ©2014 织梦吧(d8) DedeCMS学习交流平台
  • 唯一网址 www.DedeCMS8.com 网站地图
  • 联系我们 1978130638@qq.com ,  QQ