Heim > Web-Frontend > CSS-Tutorial > Hauptteil

Tipps zur Kompatibilität mit verschiedenen Browsern_CSS/HTML

WBOY
Freigeben: 2016-05-16 12:10:58
Original
1388 Leute haben es durchsucht

1,盒解释器的不同解释.

#box{   width:600px;        //for   ie6.0-   w\idth:500px;       //for  ff+ie6.0}#box{    width:600px!important            //for ff    width:600px;        //for  ff+ie6.0    width /**/:500px;       //for   ie6.0-}
2,在ie中隐藏css,使用子选择器

html>body #box{     }
3,只有ie识别

*html #box{     }
4,在ie/win有效而ie/max隐藏,使用反斜杠

/* \ */
#box{ }
5,给ie单独定义样式 这里更加详细的说明

6,浮动ie产生的双倍距离

#box{   float:left;   width:100px;   margin:0 0 0 100px;  //这种情况之下IE会产生200px的距离   display:inline;   //使浮动忽略}
这里细说一下block,inline两个元素,Block元素的特点是:总是在新行上开始,高度,宽度,行高,边距都可以控制(块元素);Inline元素的特点是:和其他元素在同一行上,...不可控制(内嵌元素);

#box{   display:block; //可以为内嵌元素模拟为块元素   display:inline; //实现同一行排列的的效果   diplay:table;   //for ff,模拟table的效果}
7,for oprea only

@media all and (min-width:0px){/* opera */#box{  }}
8,IE与宽度和高度的问题

IE不认得min-这个定义,但实际上它把正常的width和height当作有min的情况来使。这样问题就大了,如果只用宽度和高度,
正常的浏览器里这两个值就不会变,如果只用min-width和min-height的话,IE下面根本等于没有设置宽度和高度。

比如要设置背景图片,这个宽度是比较重要的。要解决这个问题,可以这样:

#box{    width: 80px;    height: 35px;}html>body #box{    width: auto;    height: auto;    min-width: 80px;    min-height: 35px;}
9,页面的最小宽度

min-width是个非常方便的CSS命令,它可以指定元素最小也不能小于某个宽度,这样就能保证排版一直正确。但IE不认得这个,而它实际上把width当做最小宽度来使。为了让这一命令在IE上也能用,可以把一个

放到 标签下,然后为div指定一个类:


然后CSS这样设计:
#container{  min-width: 600px;  width:expression(document.body.clientWidth < 600? "600px": "auto" );}
第一个min-width是正常的;但第2行的width使用了Javascript,这只有IE才认得,这也会让你的HTML文档不太正规。它实际上通过Javascript的判断来实现最小宽度。

同样的办法也可以为IE实现最大宽度:

#container{min-width: 600px;max-width: 1200px;width:expression(document.body.clientWidth < 600? "600px" : document.body.clientWidth > 1200? ”1200px“ : ”auto";}
10,清除浮动

.hackbox{       display:table; //将对象作为块元素级的表格显示}或者.hackbox{        clear:both;}
或者加入:after(伪对象),设置在对象后发生的内容,通常和content配合使用,IE不支持此伪对象,非Ie 浏览器支持,所以并不影响到IE/WIN浏览器。-------这种的最麻烦的......

#box:after{    content: ".";     display: block;    height: 0;     clear: both;     visibility: hidden;}
11,DIV浮动IE文本产生3象素的bug

左边对象浮动,右边采用外补丁的左边距来定位,右边对象内的文本会离左边有3px的间距.

#box{    float:left;    width:800px;}#left{    float:left;    width:50%;}#right{    width:50%;}*html #left{    margin-right:-3px;   //这句是关键}
   HTML代码

   
  

12, sélecteur d'attribut (ce n'est pas compatible, c'est un bug de masquage du css)

p[id]{}div[id]{}
Ceci est masqué pour IE6.0 et les versions inférieures, et fonctionne avec FF et OPera

Il existe toujours une différence entre les sélecteurs d'attributs et les sous-sélecteurs. La portée des sous-sélecteurs est réduite dans la forme, tandis que la portée des sélecteurs d'attributs est relativement grande. Par exemple, dans p[id], toutes les balises p avec. Les identifiants sont du même style.

A suivre...

Trackback : http://tb.blog.csdn.net/TrackBack.aspx?PostId=592516

Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!