Home > Web Front-end > HTML Tutorial > div css notes, about many incompatibility issues between IE and fox_html/css_WEB-ITnose

div css notes, about many incompatibility issues between IE and fox_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:29:42
Original
953 people have browsed it

I have been using Internet Explorer to make web pages. Today I went to the official Firefox website and installed one without the Google plug-in (I hate plug-ins in particular, and it is almost impossible to download Firefox without the Google plug-in in China. Browser! )
Open it and see, wow, it’s finally here, ff has a lot of incompatibility issues. Just click on the incompatibility issues and there are dozens of them. Solve them one by one slowly, search slowly, and first organize and share a few simple ones to learn.
1. The simplest CSS for mouse over hand transformation needs to change cursor:pointer; the automatic one under dw8 does not have the hand attribute anymore, the standard one is pointer
2.ff does not support filters. The most common one is Translucency is not supported.
filter: Alpha(Opacity=50);
opacity: .5;
style="-moz-opacity:0.5; filter:alpha(opacity=50);cursor:hand;" onmouseover=" this.style.MozOpacity=1;
this.filters.alpha.opacity=100" onmouseout="this.style.MozOpacity=0.5;
this.filters.alpha.opacity=50"
3. ff does not support expression_r. For example, to remove the border of the link, you need to write different css
a,area { blr:expression_r(this.onFocus=this.blur()) }
:focus { outline: none; }
4.ff does not support the color setting of the div scroll bar, and there is currently no good way to replace it.
.content {
position: absolute; left: 0px; top: 10px; width: 580px;height: 135px;
line-height:120%;text-align:left; font-family:" Songti";word-break : break-all; color:#6D6E71;
OVERFLOW-Y:auto;OVERFLOW-X:no;
SCROLLBAR-ARROW-COLOR: red; SCROLLBAR-TRACK-COLOR: F6F6F6; SCROLLBAR-FACE-COLOR:#F6F6F6;SCROLLBAR-SHADOW-COLOR:#F6F6F6;
SCROLLBAR-DARKSHADOW-COLOR:#F6F6F6;SCROLLBAR-3DLIGHT-COLOR:#F6F6F6;SCROLLBAR-HIGHLIGHT-COLOR:#F6F6F6;
}
This has no effect at all in ff.
5.ie The border-width of the horizontal line displayed below the text: 0px 0px 1px 0px; in ff it runs above the text. (I checked the manual and still couldn’t find a solution. It feels strange~~ It turns out that the fault tolerance of ff is too poor, which is caused by the following width: 186px; height: 0px;. In fact, a:haver has inherited the superior one. Attributes, just define different styles. It seems that ff helps to create standardized and concise web pages. It also has a deeper understanding of css, which is a good help for providing css)
. onelinksdiv a:hover {
display: block;border-style: solid;color: #ff0000;border-width: 0px 0px 1px 0px;

}
//The following is written under ie Normal, but wrong under ff
.onelinksdiv a:hover {
display: block;border: #ff0000 solid; border-width: 0px 0px 1px 0px;
width: 186px;height: 0px ; color: #ff0000; font-size: 14px; text-align: right;
}
Related references:
border-width:border-top-width border-right-width border-bottom- width border-left-width;
p#fourborders
{
border-width:thick medium thin 12px;
}
If four values ​​are defined, then these four values ​​are The width values ​​of the top, right, bottom and left borders (starting from the top border and traversing in counterclockwise order).
is equivalent to the following definition
p#fourborders
{
border-top -width:thick;
border-right-width:medium;
border-bottom-width:thin;
border-left-width:12px;
}
6.ff is not supported The scroll attribute must define overflow:hidden; and it must be under the html tag, not under body
html{
overflow:hidden;
}
7 .ff does not support data island bindingThe data can be loaded in IE, but the data cannot be loaded in Firefox. It may be that there are too many words in the content line, so the line cannot be broken and cannot be loaded, but it still won't work after deleting only a few words.
8.style="word-break:break-all" When the content of a cell in a web page exceeds one line, the line break style defined in IE browser can be used normally, but it is not supported in Firefox. .style="word-break:break-all" is an IE-specific attribute of MS extension and has not become a W3C standard, so Firefox cannot yet support it. However, MS has submitted it to W3C, and it can also be seen in the W3C's CSS3 candidate plan. I hope Firefox can support this property after it is finalized as a CSS3 standard by the W3C. Before this, you can try
style="table-layout:fixed;word-wrap: break-word" (when it is in English, it cannot wrap normally)
9. Currently, FF2.0 has IE's name anchor is not supported
Writing like this is not supported: go back
It turns out that according to W3C syntax, the tag will always look for the href address and jump to it. Now the onclick event conflicts with the ### address.
In order to make Firefox compatible with some element attributes of IE, I accidentally discovered that Firefox is sensitive to spaces:
//With spaces, the anchor point functions
//无空格,锚点无作用
锚点的写法又十分讲究,比如
,Firefox不支持锚点,得加上id=#1
静态同页面引用时必须这样写:
就不行,动态页面要用JS
后遗症来了,考虑到鼠标样式和浏览器兼容又开始折腾:
//不兼容
//不兼容
//没有{...},属于脚本的非法书写
//没照顾到自定义系统鼠标样式的用户
//状态栏会显现,href有多长显示多长
//我用的
10.ff火狐下面不支持document.all属性的,必需用document.getElementById('idName');
以下是我的动画切换效果,在ie下正常,到了火狐里面就不动了,修改后可以切换图片但渐隐渐现的效果就没有了。原因是火狐不支持滤镜filter,只好用半透明的div来实现了。

function playcompanyimg()
{
window.setInterval('changecompanyimg();', interval);
}
function changecompanyimg()
{

//if (document.all)
//{

   number = Math.floor(Math.random() * image.length);
idtemp.src=image[number];
//alert(number+" ii "+idtemp.src)

//alert(do_transition);
//document.all.companyimg.style.filter="progid:DXImageTransform.Microsoft.Fade(duration=2,overlap=0.4)";

var companyimgidtmep = document.getElementById('companyimg');
companyimgidtmep.style.filter="progid:DXImageTransform.Microsoft.Fade(duration=1,overlap=1)";
companyimgidtmep.filters[0].Apply();
companyimgidtmep.filters[0].Play();
//}
}
参考资料:核心:FILTER:revealTrans(duration=1,transition=23); 一个IE滤镜,
在其它的非IE浏览器虽然不支持这个滤镜,但是支持透明滤镜的,你可以分一下,IE下继续使用你这个效果,而在非IE浏览器下用透明滤镜:
style.opacity
opacity = 0.5 CSS3
style.MozOpacity
-moz-opacity: 0.5 Mozilla 里等同上面这个滤镜 这个滤镜也适用于Netscape
style.KHTMLOpacity
-khtml-opacity: 0.5 Safari 里的透明滤镜。
IE:
obj.filters.alpha.opacity
to meizz(梅花雪)
其实我想过你那个问题的。但是透明 opacity 这个他不是一个渐变的过程。
一般这种图片过度特效最多持续一秒把,最多最多两秒 duration=2
超过2秒就很累赘,喧宾夺主了。
在2秒钟里面实现
g_img.style.filter="alpha(opacity="+i+")" 透明度的变化是比较累赘的事情。
要用 window.setInterval 改变 i 的值, 而且还要调用几十上百次window.setInterval
才能看到效果。
这样的话,我觉得得不赔失,是为了特效而特效了
另外一种考虑是,毕竟非ie浏览器是少数,即使在ff下 没有图片过度特效,其实也没什么,
还是很流畅,不过就是看不到ie里面的美而已。
11.ff下链接的onclick事件不起作用

在ie下没有问题,在ff下点击了没有反应。作了多次尝试,换成onclick="display('whatwedo')"仍然不行,后来通过多次检查,搜索仍然找不到门路,最后采用惯用的方法--一步一步alert();出来看效果,原来他妈的是一个id的值写错了,但奇怪的是ie下面没有关系?是 ie的容错内容太强了还是火狐的容错内容太差了?不过还是喜欢火狐的严谨和标准哈。可以让人发现不少深层次的东西。哈哈。
12.ff中div定位不能通过js初始化 必须先设定值并且要设定度量单位 top:80px;left:212px;
13.ff不能用.click();方法打开链接,终于暂时性的解决了


hello3触发事件放在href="javascript:onclick =test2(1)" 里面ff无效

hello3



14.OVERFLOW-Y:auto ;OVERFLOW-X:hidden;It's a friend of mine, I'm not sure if it's a friend of mine
LIKE LOVE THIS IS THE LIFE A
Only one: snowflake and a snowflake, spellbinding:
4.ff snowflake div snowflake Even, the snowflakes are snowflakes and the snowflakes are snowflakes I'm not sure if I'm going to create a keyword for
7.ff but I'm going to create a database 以加载进数据, If you want to make a snowflake, you can have a snowflake and a snowflake ,you have a lot of snowflakes and you can use w3c as a snowflake, you have a snowflake For the xml settings, you can create a custom filter.
10 Thanksgiving, snowflake snowflake snowflakes, snowflakes Like)

《2》

DIV+CSS design IE6, IE7, FF compatibility
DIV+CSS web layout This is a trend, and I have begun to follow this trend. However, when using DIV+CSS website design, you should pay attention to the css style being compatible with different browsers Problem, especially for web pages designed entirely using DIV CSS, you should pay more attention to the compatibility of IE6 IE7 FF with CSS styles, otherwise, your web page may be a mess! I am often overwhelmed by these things, so I looked for some information on the Internet, combined with my own understanding and experience these days, compiled some information, some of which I have not used and cannot understand yet, just I pasted it directly from other places. I don’t know if there are any errors. I will slowly change it when I use it in the future. I hope it will be helpful to everyone!

What is browser compatibility: when we use different When using a browser (Firefox IE7 IE6) to access the same website or page, there will be some incompatibility issues. In this browser, the display is normal, but in another browser, it is messed up. When we write CSS It will be very annoying. You just fixed the problem in this browser, only to have a new problem in another browser. Okay, I'm convinced, then I'll take advantage of your incompatibility and write a piece of css each, and let them each perform their own tasks. It's time for you to lose your temper, haha.

Okay, let’s get down to business

1. !important (limited function)
With IE7’s support for !important, the !important method is now only compatible with IE6. (Pay attention to the writing. Remember that the declaration position needs to be declared in advance.)
For example:

#example {
width: 100px !important;
width: 200px;
}

2. CSS HACK method (novices can take a look, experts should just pass by)

The first thing you need to know is:

Common height for all browsers: 100px;
Special_height for IE6: 100px;
Exclusive for IE7* height: 100px;
Common to IE6 and IE7*height: 100px;
Common to IE7 and FF height: 100px !important;

For example:

#example { height:100px; }

* html #example { height:200px; }

* html #example { height:300px; }

The following This method is relatively simple

Give a few examples:

1. IE6 - IE7 FF

#example {
height:100px;
_height:200px;
}
In fact, this can also be done using the first method mentioned above
#example {
height:100px !important;
height:200px;
}

2. IE6 IE7 - FF

#example {
height:100px;
*height:200px;
}

3. IE6 FF - IE7

#example {
height:100px;
* height:200px;
}

4. IE6 IE7 FF are different

#example {
height:100px;
_height:200px;
* height:300px;
}
or:
#example {
height:100px;
*height:300px;
_height:200px;
}

It should be noted that the order of the codes must not be reversed, otherwise all previous efforts will be wasted. Because when the browser interprets the program, if the name is the same, it will overwrite the previous one with the later one, just like assigning a value to a variable, so we put the general ones in the front, and the more specialized ones, the later

Explain the code of 4:

When reading the code, the first line height: 100px; is common to everyone, IE6 IE7 FF all displays 100px
When it comes to the second line *height: 300px; FF does not recognize this attribute, IE6 and IE7 both recognize it, so FF still displays 100px, but IE6 and IE7 overwrite the height attribute obtained in the first line, and both display 300px
and the third line _height:200px; only IE6 recognizes it, so IE6 It overwrites the height obtained in the second line, and finally displays 200px
In this way, the three browsers have their own height attribute, let each play with it

If you don’t understand yet , either you go to hit the wall, or I go! But it’s better for you to go.

Oh, I almost forgot to mention:
* To be compatible with IE7, html must have the following statement at the top of the HTML:



3. Use IE-specific conditional comments

< ;!--Other browsers-->



< !--[if IE 7]>













貌似要编三套css,我还没用过,先粘过来再说

IE的if条件Hack

1. 除IE外都可识别
2.
3.
4.
5.
6.
7.
8.
9.
10.
11. 注:gt = Great Then 大于
> = > 大于号
lt = Less Then 小于
< = < 小于号
gte = Great Then or Equal 大于或等于
lte = Less Then or Equal 小于或等于

四、css filter的办法(据作者称是从国外某经典网站翻译过来的说)

新建一个css样式如下:

#item {

width: 200px;

height: 200px;

background: red;

}

新建一个div,并使用前面定义的css的样式:

some text here


在body表现这里加入lang属性,中文为zh:



现在对div元素再定义一个样式:

*:lang(en) #item{

background:green !important;

}

这样做是为了用!important覆盖原来的css样式,由于:lang选择器ie7.0并不支持,所以对这句话不会有任何作用,于是也达到了ie6.0下同样的效果,但是很不幸地的是,safari同样不支持此属性,所以需要加入以下css样式:

#item:empty {

background: green !important

}

:empty选择器为css3的规范,尽管safari并不支持此规范,但是还是会选择此元素,不管是否此元素存在,现在绿色会现在在除ie各版本以外的浏览器上。


五、FLOAT闭合(clearing float)

  网页在某些浏览器上显示错位很多时候都是因为使用了float浮动而没有真正闭合,这也是div无法自适应高度的一个原因。如果父div没有设float而其子div却设了float的话,父div无法包住整个子DIV,这种情况一般出现在一个父DIV下包含多个子DIV。解决办法:

1、给父DIV也设上float(不要骂我,我知道是废话)

2、在所有子DIV后新加一个空DIV(不推荐,有些浏览器可以看见空DIV产生的空隙)

比如:

.parent{width:100px;}
.son1{float:left;width:20px;}
.son2{float:left;width:80px;}
.clear{clear:both;margin:0;parding0;height:0px;font-size:0px;}







3、万能 float 闭合

将以下代码加入Global CSS 中,给需要闭合的div加上 class=”clearfix” 即可,屡试不爽.
代码:


:after(伪对象),设置在对象后发生的内容,通常和content配合使用,IE不支持此伪对象,非Ie 浏览器支持,所以并不影响到IE/WIN浏览器。这种的最麻烦。

4、overflow:auto(刚看到的,极力推荐)

只要在父DIV的CSS中加上overflow:auto就搞定。

举例:

.parent{width:100px;overflow:auto}
.son1{float:left;width:20px;}
.son2{float:left;width:80px;}






作者原话:原理是,外围元素之所以不能很好的延伸,问题出在了overflow上,因为overflow不可见(见W3C的解释)。现在只要将给外围元素添加一个“overflow:auto”,就可以解决问题,结果是除了IE,真的可以解决。下来就要解决IE的问题了,再加上“_height:1%”,这个问题就完全解决了。

我试了一下,其实不加"_height:1%“在IE下也行,留着吧。

六、需要注意的一些兼容细节

1, FF下给 div 设置 padding 后会导致 width 和 height 增加(DIV的实际宽度=DIV宽+Padding), 但IE不会.

解决办法:给DIV设定IE、FF两个宽度,在IE的宽度前加上IE特有标记" * "号。

2, 页面居中问题.

body {TEXT-ALIGN: center;} 在IE下足够了,但FF下失效。

解决办法:加上"MARGIN-RIGHT: auto; MARGIN-LEFT: auto; "

3, 有的时候在IE6上看见一些奇怪的间隙,可我们高度明明设好了呀。

解决办法:试试在有空隙的DIV上加上"font-size:0px;"

4, 关于手形光标. cursor: pointer. 而hand 只适用于 IE.

5, 浮动IE6产生的双倍距离

#box{ float:left;
width:100px;
margin:0 0 0 100px;
}
这种情况之下IE6会产生200px的距离

解决办法:加上display:inline,使浮动忽略

这里细说一下block,inline两个元素,Block元素的特点是:总是在新行上开始,高度,宽度,行高,边距都可以控制(块元素);Inline元素的特点是:和其他元素在同一行上,…不可控制(内嵌元素);
#box{ display:block; //可以为内嵌元素模拟为块元素 display:inline; //实现同一行排列的的效果

6 页面的最小宽度

min-width是个非常方便的CSS命令,它可以指定元素最小也不能小于某个宽度,这样就能保证排版一直正确。但IE不认得min-这个定义,但实际上它把正常的width和height当作有min的情况来使。这样问题就大了,如果只用宽度和高度,正常的浏览器里这两个值就不会变,如果只用min-width和min-height的话,IE下面根本等于没有设置宽度和高度。比如要设置背景图片,这个宽度是比较重要的。

解决办法:为了让这一命令在IE上也能用,可以把一个
放到 标签下,然后为div指定一个类:
然后CSS这样设计:
#container{
min-width: 600px;
width:e­xpression(document.body.clientWidth < 600? “600px”: “auto” );
}
第一个min-width是正常的;但第2行的width使用了Javascript,这只有IE才认得,这也会让你的HTML文档不太正规。它实际上通过Javascript的判断来实现最小宽度。

7、UL和FORM标签的padding与margin

ul标签在FF中默认是有padding值的,而在IE中只有margin默认有值。FORM标签在IE中,将会自动margin一些边距,而在FF中margin则是0;

解决办法:css中首先都使用这样的样式ul,form{margin:0;padding:0;}给定义死了,后面就不会为这个头疼了.

8 ,DIV浮动IE文本产生3象素的bug

下面这段是我在网上粘过来的

左边对象浮动,右边采用外补丁的左边距来定位,右边对象内的文本会离左边有3px的间距.
#box{
float:left;
width:800px;}
#left{
float:left;
width:50%;}
#right{
width:50%;
}
*html #left{
margin-right:-3px;
//这句是关键
}
HTML代码





Regarding the above code, here is my understanding:

First, as long as right defines the width attribute, it will definitely be displayed in two lines under FF
Second . If both widths are defined as percentages, even if they are both 100%, they will still be displayed in one line under IE. Therefore, the so-called "this sentence is the key" above is completely useless. It is still on the same line without adding it, unless your width is defined as a numerical value.

So the above code is actually not very useful, at least not under FF. In fact, as long as you only define the width of left, it will be successful in IE or FF without defining the width of right. However, in this case, the parent DIV BOX does not really contain the two child DIVs LEFT and RIGHT. You can use the first method I mentioned above. 5 ways to solve it. The simplest way is to add float:left to RIGHT and that's it. It's really annoying!


9, truncation ellipsis

.hh { -o-text-overflow:ellipsis;
text-overflow:ellipsis;
white-space:
nowrapoverflow:hidden;
}
This will automatically cut off the excess text after exceeding the length, and end with an ellipsis. Technology is good technology, and many people like to use it randomly, but please note that Firefox does not support it.

div css notes, about many incompatibility issues between IE and fox

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template