1、居中问题

div里的内容,IE默认为居中,而FF默认为左对齐,可以尝试增加代码margin: 0 auto;

2、高度问题

两上下排列或嵌套的div,上面的div设置高度(height),如果div里的实际内容大于所设高度,在FF中会出现两个div重叠的现象;但在IE中,下面的div会自动给上面的div让出空间所以为避免出现层的重叠,高度一定要控制恰当,或者干脆不写高度,让他自动调节,比较好的方法是 height:100%;但当这个div里面一级的元素都float了的时候,则需要在div块的最后,闭和前加一个沉底的空div,对应CSS是:.float_bottom {clear:both;height:0px;font-size:0px;padding:0;margin:0;border:0;line-height:0px;overflow:hidden;}

3、清除浮动的几种方法

clear:both; 不想受到float浮动的,就在div中写入clear:both;

4、IE浮动 margin产生的双倍距离

#box {

float:left;

width:100px;

margin:0 0 0 100px; //这种情况之下IE会产生200px的距离

display:inline; //使浮动忽略

}

5、padding问题

FF设置 padding 后,div会增加 height 和 width,但IE不会 (* 标准的 XHTML1.0 定义 dtd 好像一致了)高度控制恰当,或尝试使用 height:100%;宽度减少使用 padding但根据实际经验,一般FF和IE的 padding 不会有太大区别,div 的实际宽 = width + padding ,所以div写全 width 和 padding,width 用实际想要的宽减去 padding 定义。

6、div嵌套时 y轴上 padding和 marign的问题

FF里 y 轴上 子div 到 父div 的距离为 父padding + 子marign

IE里 y 轴上 子div 到 父div 的距离为 父padding 和 子marign 里大的一个

FF里 y 轴上 父padding=0 且 border=0 时,子div 到 父div 的距离为0,子marign 作用到 父div 外面

7、padding,marign,height,width的傻瓜式解决技巧

注意是技巧,不是方法:

写好标准头

<!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”>

高尽量用padding,慎用margin,height尽量补上100%,父级height有定值子级height不用100%,子级全为浮动时底部补个空clear:both的div宽尽量用margin,慎用padding,width算准实际要的减去padding

8、列表类

1. ul标签在FF中默认是有 padding值的,而在IE中只有margin有值

先定义 ul {margin:0;padding:0;}

2. ul和ol列表缩进问题消除ul、ol等列表的缩进时,样式应写成: {list-style:none;margin:0px;padding:0px;}

9、显示类(display:block,inline)

①. display:block,inline两个元素

display:block; //可以为内嵌元素模拟为块元素

display:inline; //实现同一行排列的的效果

display:table; //for FF,模拟table的效果

display:block 块元素,元素的特点是:

总是在新行上开始;高度,行高以及顶和底边距都可控制;宽度缺省是它的容器的100%,除非设定一个宽度

<div>,<p>,<h1>,<form>,<ul> 和 <li> 是块元素的例子

display:inline 就是将元素显示为行内元素,元素的特点是:和其他元素都在一行上;高,行高及顶和底边距不可改变;宽度就是它的文字或图片的宽度,不可改变。<span>,<a>,<label>,<input>,<img>,<strong> 和 <em> 是 inline 元素的例子

②.鼠标手指状显示

全部用标准的写法 cursor: pointer;

10、背景、图片类

①. background显示问题

全部注意补齐 width,height 属性

②.背景透明问题

IE: filter: progid: DXImageTransform.Microsoft.Alpha(style=0,opacity=60);

IE: filter: alpha(opacity=10);

FF: opacity:0.6;

FF: -moz-opacity:0.10;

最好两个都写,并将opacity属性放在下面

11、min-height最小高度的实现(兼容IE6、IE7、FF)

作用是:当容器的内容较少时,能保持一个最小的高度,以免破坏了布局或UI设计效果。而当容器内的内容增加的时候,容器能够自动的伸展以适应内容的变化。

#mrjin {

background:#ccc;

min-height:100px;

height:auto !important;

height:100px;

overflow:visible;

}

12、著名的 Meyer Reset(重置)

html, body, div, span, applet, object, iframe,h1, h2, h3, h4, h5, h6,p, blockquote, pre,a, abbr, acronym, address, big, cite, code,del, dfn, em, font, img, ins, kbd, q, s, samp,small, strike, strong, sub, sup, tt, var,dl, dt, dd, ol, ul, li,fieldset, form, label, legend,table, caption, tbody, tfoot, thead, tr, th, td

{

margin: 0;

padding: 0;

border: 0;

outline: 0;

font-weight: inherit;

font-style: inherit;

font-size: 100%;

font-family: inherit;

vertical-align: baseline;

}

:focus {

outline: 0;

}

body {

line-height: 1;

color: black;

background: white;

}

ol, ul {

list-style: none;

}

table {

border-collapse: separate;

border-spacing: 0;

}

caption, th, td {

text-align: left;

font-weight: normal;

}

blockquote:before, blockquote:after,

q:before, q:after {

content: "";

}

blockquote, q {

quotes: "" "";

}

13、跨浏览器的CSS透明度

.transparent {

opacity: 0.7;

-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";

filter: alpha(opacity=70);

-moz-opacity: 0.7;

-khtml-opacity: 0.7;

14、文字阴影(CSS3)

.text { text-shadow: 1px 1px 1px #666; filter: Shadow(Color=#666666, Direction=135, Strength=5); }

15、Box阴影(CSS3)

.box { box-shadow: 5px 5px 5px #666; -moz-box-shadow: 5px 5px 5px #666; -webkit-box-shadow: 5px 5px 5px #666; }

16、Sticky Footer (让页脚永远停靠在页面底部,而不是根据绝对位置)

<div id="wrap">

<div id="main" class="clearfix"></div>

</div>

<div id="footer"> </div>

CSS:

* { margin:0; padding:0; }

html, body, #wrap { height: 100%; }

body > #wrap {height: auto; min-height: 100%;}

#main { padding-bottom: 150px; }

#footer {

position: relative;

margin-top: -150px;

height: 150px;

clear:both;}

.clearfix:after {content: ".";

display: block;

height: 0;

clear: both;

visibility: hidden;}

.clearfix {display: inline-block;}

* html .clearfix { height: 1%;}

.clearfix {display: block;}

17、iframe元素內嵌頁面如何去掉继承的html及body背景色/背景图片

iframe元素的功能是在一个文档里内嵌一个文档,创建一个浮动的帧。内嵌文档时一个完整的页面,有HTML,BODY等属性。这样遇到了一个问题,如果样式表中对BODY定义过背景色/背景图片,那么内嵌文档将全部继承过来。所以如何去掉背景色和背景图片:

【1】去掉背景色:filter:Chroma(Color=white);

举例:<iframe width="100%" height="400" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" leftmargin="0" topmargin="0" style="filter:Chroma(Color=white);" ></iframe>

【2】去掉背景图片:

举例:<iframe width="100%" height="400" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" leftmargin="0" topmargin="0" style="filter:Chroma(Color=white);" allowTransparency="true" ></iframe>

注意:内嵌页面同时也要增加BODY属性:

<body bgcolor="transparent" style='background:transparent'>

18、为什么web标准中无法设置IE浏览器滚动条颜色了?

原来样式设置:

<style type="text/css">

body{scrollbar-face-color:#f6f6f6; scrollbar-highlight-color:#fff; scrollbar-shadow-color:#eeeeee; scrollbar-3dlight-color:#eeeeee; scrollbar-arrow-color:#000; scrollbar-track-color:#fff; scrollbar-darkshadow-color:#fff; }

</style>

解决办法是将body换成html。

19、为什么中火狐浏览器下文本无法撑开容器的高度?

标准浏览器中固定高度值的容器是不会象IE6里那样被撑开的,那我又想固定高度,又想能被撑开需要怎样设置呢?办法就是去掉height设置min-height:200px; 这里为了照顾不认识min-height的IE6 可以这样定义:

div { height:auto!important; height:200px; min-height:200px; }

20、如何定义1px左右高度的容器?

IE6下这个问题是因为默认的行高造成的,解决的方法也有很多,例如:overflow:hidden | zoom:0.08 | line-height:1px

21、怎么样才能让层显示在FLASH之上呢?

解决的办法是给FLASH设置透明:

<a href="http://www.chinaz.com/">:</a>

<pre lang="html" line="1">

<param name="wmode" value="transparent" />

22、怎样使一个div层居中于浏览器中?

<style type="text/css">

<!--

div {

position:absolute;

top:50%;

left:50%;

margin:-100px 0 0 -100px;

width:200px;

height:200px;

border:1px solid red;

}

-->

</style>

23、怎样使div背景透明?

首先,需要这两个层都是兄弟关系,其次,这两个层都需要绝对定位。举个例子:

<!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" />

<meta name="author" content="colinivy" />

<title> Colinivy's world</title>

<style type="text/css">

body {

font:normal 12px/30px Verdana; }

#test {

position:relative;

width:400px;

height:50px;

}

#inner {

z-index:2;

position:absolute;

top:10px;

left:10px;

width:380px;

height:30px;

color:#003;

font-weight:bold;

text-align:center;

}

#transbox {

z-index:1;

position:absolute;

top:0px;

left:0px;

width:400px;

height:50px;

background:#eef;

border:1px solid #a00;

filter:alpha(opacity=40);

-moz-opacity:0.4;

opacity:0.4;

}

</style>

</head>

<body>

<div id="test">

<div>

<p>这里很多的文字,这里很多的文字,这里很多的文字,这里很多的文字,</p>

</div>

<div id="transbox"></div>

<div id="inner">

BlueIdea,BlueIdea,BlueIdea

</div>

</div>

</body>

</html>

24、怎样去掉选中时的虚线框?

利用οnfοcus="this.blur();"例如:<a href="#" οnfοcus="this.blur();">测试</a>

25、ie6下png背景显示问题?

针对ie6下png背景显示问题,CSS中可以这样解决:_background:none;_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=crop, src=’http://www.0351zhuangxiu.com/uploads/images/bj.jpg’);

26、文字与表单对齐方法?

设置表单元素第一字体为Tahoma(Verdana系列也可),并设置vertical-align:middle.建设大家把这个约定写入CSS RESET中,能减小很多麻烦:

body,button,input,select,textarea{font:12px/1.5 tahoma,arial,sans-serif; vertical-align:middle}

27、optgroup标签的用法?

optgroup标签,鲜为人知,它对提升选择表单用户体验很有帮助。就是可以在有很多选项时,对这些选项分组:例子:

<select id="selectId">

<optgroup label="GROUP ONE">

<option value="1">one select</option>

<option value="2">two select</option>

</optgroup>

<optgroup label="GROUP TWO">

<option value="3">three select</option>

<option value="4">four select</option>

</optgroup>

</select>

28、文字与图片垂直居中对齐方法?

为图片与文字的共同父元素所有的后代元素定义*{vertical-align:middle};例如:

<p>我要的坚强<img src="i/image.gif" /></p>

只需定义p*{vertical-align:middle}即可使文字与图片同行垂直居中.

29、文章标题列表中日期居右显示的两种方法?

方法A相对方法B省资源,但比方法B要多写两句代码,使用时请视情况而定:

方法A:

<p>这是文章标题<span>2010-10-10</span></p>

然后定义p和span的样式:

p{ position:relative}

p span{ position:absolute; right:0}

方法B:

<p><span>2010-10-10</span>这是文章标题</p>

然后定义span右浮动:

p span{float:right}

30、ie6下max/min-width/height实现?

ie6下max/min-width/height实现,_width: expression_r(this.width >600 ? “600px” : true);,height同理.

31、空白外边距互相叠加的问题?

一般通过添加透明边框或者1px的内边距避免;

其一,为外围元素定义透明边框.具体到本例,即在样式div中加入border:1px solid transparent;

其二,为外围元素定义内边距填充..具体到本例,即在样式div中加入padding:1px;

例如:<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>空白边距叠加demo@Mr.Think</title>

<style>

body{width:300px; font-family:'微软雅黑'; font-size:1em; text-indent:10px; line-height:1.25}

div{background:#a40000;margin:10px}

div p{background:#eee;margin:15px}

</style>

</head>

<body>

<div><p>空白边距叠加demo@Mr.Think</p></div>

</body>

</html>

32、网页设计中的默认字体

font: 12px/1.5 Tahoma, Helvetica, Arial, sans-serif;

说明:line-height采用1.5, 也就是18px. 这是淘宝视觉规范中定义的行高,对于12px字体,这个行高看起来很舒服。font-family默认采用Tahoma. Tahoma是英文Windows操作系统的默认字体,这个字体比较均衡,显示中英文混排很不错,是经久耐看的一款字体。

33、浏览器兼容——常用的css hack

(1).title{ height:200px;

*height:200px;

_height:200px; }

(2).title{ height:200px;

*height:200px !important;

*height:200px; }

(3).title{ height:200px; }

*html.title{ height:200px;}

*+html.title{ height:200px;}

转载于:https://www.cnblogs.com/heyiming/p/7007481.html

css兼容问题收集+部分效果收集+css重置相关推荐

  1. css兼容IE8 及最新IE8 css hack

    微软在IE8提供三种解析页面的模式IE8 Standard Modes :默认的最标准的模式,严格按照W3C相关规定IE7 Standards Modes :IE7现在用的解析网页的模式,开起机关是在 ...

  2. CSS兼容IE/Firefox要点

    首先我们说说firefox和IE对CSS的宽度显示有什么不同: 其实CSS 'width' 指的是标准CSS中所指的width的宽度,在firefox中的宽度就是这个宽度.它只包含容器中内容的宽度.而 ...

  3. 关于CSS兼容IE与Firefox要点分析

    原文引用:http://blog.sina.com.cn/u/4a46bf5b010009ei 发现很多站点对Firefox的兼容性不是很好,往往导致页面排版混乱的现象,尤其是WEB2.0火热的今天, ...

  4. html网页改兼容模型,让DIV+CSS兼容所有浏览器

    1.DOCTYPE 影响 CSS 处理 2.FF: div 设置 margin-left, margin-right 为 auto 时已经居中, IE 不行 3.FF: body 设置 text-al ...

  5. IE6.0、IE7.0 与FireFox CSS兼容的解决方法

    1.DOCTYPE 影响 CSS 处理 2.FF: div 设置 margin-left, margin-right 为 auto 时已经居中, IE 不行 3.FF: body 设置 text-al ...

  6. CSS样式大全(网络收集整理)

    CSS样式大全(网络收集整理 字体属性:(font) 大小 {font-size: x-large;}(特大) xx-small;(极小) 一般中文用不到,只要用数值就可以,单位:PX.PD 样式 { ...

  7. 在线CSS工具及相关资源收集

    在线CSS工具: W3C CSS 校验服务 :提供万维网协会(W3C)样式表(CSS)校验服务. CSS 在线编辑器:OnLine CSS Designer - CSS Style Editor. C ...

  8. 各浏览器CSS兼容问题

    CSS对浏览器的兼容性有时让人很头疼,或许当你了解当中的技巧跟原理,就会觉得也不是难事,从网上收集了IE7,6与Fireofx的兼容性处理方法并 整理了一下.对于web2.0的过度,请尽量用xhtml ...

  9. 让CSS兼容IE和Firefox的技巧集合

    CSS对浏览器的兼容性有时让人很头疼,或许当你了解当中的技巧跟原理,就会觉得也不是难事,从网上收集了IE7,6与Fireofx的兼容性处理方法并整理了一下.对于web2.0的过度,请尽量用xhtml格 ...

最新文章

  1. Visual Studio 2017 15.7预览版发布
  2. 也谈Javascript的效率,createElement和innerHTML,为innerHTML平反
  3. ROS系统 参数的获取和设置
  4. GitHub Port 443 Refused
  5. 我的小型网站搜索分词中遇到的问题
  6. ubuntu14.04 64bit主机下面安装android的NDK开发环境
  7. python opencv 实现从一个文件夹中读取图片做切割处理后放入另一个文件夹
  8. 修改itunes备份路径的方法(奇奇怪怪的文件堆积C盘,别让文件成为最后的稻草哦)
  9. Js中对id和class属性进行模糊查询
  10. 【高级内部资料】.NET数据批量写入性能分析 第一篇
  11. ios 团购信息客户端demo(二)
  12. 诺基亚N9—刷机教程
  13. 揭秘跨境电商亚马逊店铺新手培训骗局!有人已经被骗了好几万了!
  14. Zynga公布2020年第三季度财务业绩
  15. 小米html查看器 联网,小米摄像机如何连接无线路由器通过手机查看
  16. 共享经济思考:标准化与个性化如何融合
  17. 【地图导航】3D地图软件是如何做路径规划的?为什么准确率这么高
  18. CTFshow新春欢乐赛--web6--反序列化字符串逃逸
  19. python 白噪声检验-时间序列 平稳性检验 白噪声 峰度 偏度
  20. 电线电缆使用时的安全要求和存放方法

热门文章

  1. Announcing Windows Template Studio in UWP
  2. 快速记忆HTTP状态码
  3. 长江智能航道研发与应用现状与展望
  4. 关于Jmeter一直报红
  5. vue中的input使用e.target.value赋值的问题
  6. SharePoint网站
  7. SharePoint网站搜索规则(Search Query )
  8. 华为oj-名字的漂亮度
  9. 豆瓣电影ajax数据获取并保存到本地
  10. PHP strtotime函数参数