完美WEB

css,xhtml,javascript,DOM,亲和力,web内容可用性教程,希望web变得更完美。

« DOCTYPE(文档类型)水平分隔线标签hr是“表现标签”吗? »

IE盒模型bug和修复

Internet Explore(简称IE)是目前使用得最多的浏览器,在国内几乎是一统天下。IE6以前的版本对“盒模型(box model)”执行了错误的解释。如果一个盒的宽度为200px,边距为20px,边框大小为20px,如下CSS定义:

 div { width : 200px; padding: 20px; border:20px   solid #60A179; } 

根据W3C的css规范来计算的话,整个盒的宽度是: 内容(200px) +边距 (20px+20px) + 边框(20px+20px) = 280px. 然而IE6以前的版本认为:内容 +边距 + 边框 = 200px.所以内容的真正宽度为:200-20-20-20-20=120px 。如下图所示: 盒模型示意图 为了修复这个bug,可以采用一个技巧:即增加一个IE5和IE5.5不能解释的声音属性"voice-family",读到这个定义时浏览器就不再继续阅读,认为宽就是300px,但而其他符合标准的浏览器会继续阅读,并执行第二个真实值200px。如下CSS定义:

 div { width : 300px; padding: 20px; border:20px solid #60A179; voice-family : "\"}\""; voice-family :inherit; width : 200px; } 

当然了,还有其他方法(英文资料)解决这个bug。关于盒模型你也可以浏览阿捷网站上的盒模型bug的解决方法这篇文章。

阅读更多的CSS书籍

此文禁止转载,但是您可以以超级链接的方式链接到这篇文章。

  • ambian(引用)
  • ambian
  • admins whos create this site, thanks guys.
  • 2007-5-16 15:03:35
  • hudia(引用)
  • hudia
  • admins whos create this site, thanks guys.
  • 2007-5-16 15:03:45
  • tadalefil(引用)
  • tadalefil
  • Hello, Glad to find your site. Just one more time I want to thank the
  • 2007-5-16 15:18:32
  • ellegra(引用)
  • ellegra
  • you think my sites too brilliant?
  • 2007-5-16 15:31:33
  • zyrtek(引用)
  • zyrtek
  • Very interesting site!
  • 2007-5-16 15:31:36
  • siales(引用)
  • siales
  • Very interesting site!
  • 2007-5-16 15:36:02
  • xenikal(引用)
  • xenikal
  • admins whos create this site, thanks guys.
  • 2007-5-17 16:26:28
  • tramdol(引用)
  • tramdol
  • you think my sites too brilliant?
  • 2007-5-21 8:24:58
  • addipex(引用)
  • addipex
  • admins whos create this site, thanks guys.
  • 2007-5-23 1:13:02
  • tramadol.com(引用)
  • tramadol.com
  • Hello, Glad to find your site. Just one more time I want to thank the
  • 2007-5-23 1:22:59
  • prosac(引用)
  • prosac
  • Hello, Glad to find your site. Just one more time I want to thank the
  • 2007-5-28 2:37:24
  • zolloft(引用)
  • zolloft
  • you think my sites too brilliant?
  • 2007-5-28 2:38:12
  • xanaflex(引用)
  • xanaflex
  • Hello, Glad to find your site. Just one more time I want to thank the
  • 2007-5-28 2:39:16
  • paxile(引用)
  • paxile
  • admins whos create this site, thanks guys.
  • 2007-5-28 2:39:18
  • zybann(引用)
  • zybann
  • Hello, Glad to find your site. Just one more time I want to thank the
  • 2007-5-28 2:56:20
  • adivan(引用)
  • adivan
  • Now I dont have to feel so intimated by science!
  • 2007-5-28 2:56:35
  • xenikal(引用)
  • xenikal
  • admins whos create this site, thanks guys.
  • 2007-5-28 6:01:20
  • aderall(引用)
  • aderall
  • Now I dont have to feel so intimated by science!
  • 2007-6-1 22:48:23
  • ionamen(引用)
  • ionamen
  • Hello man, your site best, ciao!
  • 2007-6-1 22:49:46
  • ambein(引用)
  • ambein
  • admins whos create this site, thanks guys.
  • 2007-6-1 22:51:27
  • hudia(引用)
  • hudia
  • Very interesting site!
  • 2007-6-1 22:51:52
  • fioriset(引用)
  • fioriset
  • Now I dont have to feel so intimated by science!
  • 2007-6-2 4:31:09
  • ziban(引用)
  • ziban
  • admins whos create this site, thanks guys.
  • 2007-6-2 5:11:32
  • zanax(引用)
  • zanax
  • Very interesting site!
  • 2007-6-2 13:14:49
  • propicia(引用)
  • propicia
  • Hello, Glad to find your site. Just one more time I want to thank the
  • 2007-6-2 13:15:06
  • meredia(引用)
  • meredia
  • Now I dont have to feel so intimated by science!
  • 2007-6-4 1:06:41
  • ellegra(引用)
  • ellegra
  • you think my sites too brilliant?
  • 2007-6-5 17:42:11
  • codein(引用)
  • codein
  • you think my sites too brilliant?
  • 2007-6-8 5:43:14
  • xennical(引用)
  • xennical
  • Now I dont have to feel so intimated by science!
  • 2007-6-8 5:43:57
  • livitra(引用)
  • livitra
  • Hello man, your site best, ciao!
  • 2007-6-8 5:46:00
  • cialias(引用)
  • cialias
  • Hello man, your site best, ciao!
  • 2007-6-8 5:52:49
  • aderall(引用)
  • aderall
  • you think my sites too brilliant?
  • 2007-6-8 14:11:52
  • ambian(引用)
  • ambian
  • Hello, Glad to find your site. Just one more time I want to thank the
  • 2007-6-8 14:59:19
  • ionamen(引用)
  • ionamen
  • admins whos create this site, thanks guys.
  • 2007-6-15 8:32:23
  • meredia(引用)
  • meredia
  • you think my sites too brilliant?
  • 2007-6-15 8:44:14
  • zanoflex(引用)
  • zanoflex
  • admins whos create this site, thanks guys.
  • 2007-6-15 9:00:12
  • paxile(引用)
  • paxile
  • you think my sites too brilliant?
  • 2007-6-15 9:00:18
  • flexril(引用)
  • flexril
  • you think my sites too brilliant?
  • 2007-6-15 9:00:25
  • ultracete(引用)
  • ultracete
  • admins whos create this site, thanks guys.
  • 2007-6-15 9:03:12
  • vicadin(引用)
  • vicadin
  • you think my sites too brilliant?
  • 2007-6-15 9:03:22
  • ulltram(引用)
  • ulltram
  • Hello man, your site best, ciao!
  • 2007-6-15 9:03:28
  • zitromax(引用)
  • zitromax
  • Now I dont have to feel so intimated by science!
  • 2007-6-16 5:15:31
  • prosac(引用)
  • prosac
  • you think my sites too brilliant?
  • 2007-6-19 1:50:38
  • zannaflex(引用)
  • zannaflex
  • admins whos create this site, thanks guys.
  • 2007-6-19 3:15:04
  • zolloft(引用)
  • zolloft
  • you think my sites too brilliant?
  • 2007-6-21 21:35:49
  • xannax(引用)
  • xannax
  • you think my sites too brilliant?
  • 2007-6-21 21:43:21
  • ellegra(引用)
  • ellegra
  • you think my sites too brilliant?
  • 2007-6-21 21:45:46
  • zyrtek(引用)
  • zyrtek
  • you think my sites too brilliant?
  • 2007-6-21 21:45:51
  • zybann(引用)
  • zybann
  • Now I dont have to feel so intimated by science!
  • 2007-6-21 21:54:59
  • cyalis(引用)
  • cyalis
  • Hello man, your site best, ciao!
  • 2007-6-22 1:07:11
  • zybann(引用)
  • zybann
  • Hello man, your site best, ciao!
  • 2007-6-22 12:09:55
  • xannax(引用)
  • xannax
  • Hello man, your site best, ciao!
  • 2007-6-22 12:17:58
  • valum(引用)
  • valum
  • you think my sites too brilliant?
  • 2007-6-23 12:39:45
  • valtrax(引用)
  • valtrax
  • you think my sites too brilliant?
  • 2007-6-23 12:41:02
  • lepitor(引用)
  • lepitor
  • admins whos create this site, thanks guys.
  • 2007-6-23 12:44:58
  • ativane(引用)
  • ativane
  • Now I dont have to feel so intimated by science!
  • 2007-6-23 12:58:14
  • xenicall(引用)
  • xenicall
  • you think my sites too brilliant?
  • 2007-6-23 16:42:48
  • ativane(引用)
  • ativane
  • you think my sites too brilliant?
  • 2007-6-24 3:47:46
  • valum(引用)
  • valum
  • you think my sites too brilliant?
  • 2007-6-24 3:48:11

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。



日历

网站目录

最新评论

最近发表

Powered By Z-Blog 1.6 Beta Build 60420

Copyright flashshe.com All Rights Reserved.