前端兼容性问题总结(PC端)
1.如果图片加a标签在IE9-中会有边框
解决方案:
img{border:none;}
2.rgba不支持IE8
解决方案:可以用 opacity
eg:
opacity:0.7;/FF chrome safari opera/ filter:alpha(opacity:70);/用了ie滤镜,可以兼容ie/
,需要注意的是,opacity会影响里面元素的透明度
3. display:le-block ie6/7不支持
解决方案:
display:le-block; display:le;
4.默认的body没有body去掉marg情况下ie5、6、7边缘会很宽marg-加倍 如果处于无声明状态那么所有的ie浏览器marg-加倍
解决方案:用css给body添加mag属性为0px
body{marg:0;}
5.IE 6.0 Firefox Opera等是 真实宽度=width+paddg+border
IE5.X 真实宽度=width
解决方案:
方法1.
div.content { width:400px; //这个是错误的width(对于ie5来说是正确的),所有浏览器都读到了 voice-family: "\"}\""; //IE5.X/w忽略了"\"}\""后的内容 voice-family:herit; width:300px; //包括IE6/w在内的部分浏览器读到这句,新的数值(300px)覆盖掉了旧的 }
方法2.
div.content { width:300px !important; //这个是正确的width,大部分支持!important标记的浏览器使用这里的数值 width(空格)//:400px; //IE6/w不解析这句,所以IE6/w仍然认为width的值是300px;而IE5.X/w读到这句,新的数值(400px)覆盖掉了旧的,因为!important标记对他们不起作用 }
6.height不能小于16px,设置较小高度标签(一般小于10px),在IE6,IE7,遨游中高度超出自己设置高度
解决方案:overflow设置为hidden
7.m-height不兼容 ie6 7解释为超过高度就撑开,而其他版本浏览器则遮盖狼蚁网站SEO优化的层
解决方案:m-height:200px; height:auto !important; height:200px; overflow:visible;
8.position:fixed IE5、6无法识别此属性
解决方案:
<!--[if lte IE 6]> <style type="text/css"> html { /这个可以让IE6下滚动时无抖动/ background: url(about:black) no-repeat fixed } #demo_t, #demo_b, #demo_l, #demo_r { position: absolute; } #demo_t, #demo_b { /这个解决body有paddg时,IE6下100%不能铺满的问题/ width: expression(offsetParent.clientWidth); } /狼蚁网站SEO优化三组规则用于IE6下计算/ #demo_l, #demo_r { : expression(offsetParent.scrollTop + 300); } #demo_t { : expression(offsetParent.scrollTop); } #demo_b { : expression(offsetParent.scrollTop + offsetParent.clientHeight-offsetHeight); } </style> <![endif]-->
9.浮动的div有marg_left属性ie6会加倍 无论兼容视图还是无声明视图
解决方案:
方案一: IE6唯一识别属性_的方式加_display属性_display:le;
方案二:
条件注释<!--[if lte IE 6]> <style> .on{ display:le } </style> <![endif]-->
10.cursor兼容 自定义指针cur格式的图片url路径问题无论是兼容还是无声明版本
解决方案:cursor:url(Hand.cur), url(/Hand.cur), auto;
11.png图片 IE6里面的png图片不能透明 兼容版本和无声明版本都是
解决方案:
<!--[if IE ]> <style type="text/css"> #DIVname{ background:none; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizgMethod=scale, src="pngtoumg.png" } </style> <![endif]-->
12.img浮动 img标签打回车会造成每个图片之间有缝隙
解决方案:可以删除之间的回车键也可以让这些图片浮动
13.在IE浏览器下 put type="text"文本框点击时后面会出现"X",以及type="password"后面会出现眼睛,如何除去这两种默认样式:
::-ms-clear,::-ms-reveal{display:none;}
注:IE9-不识别
14.CSS3前缀 -webkit- webkit渲染引擎 chrome/safari
-moz- gecko渲染引擎 firefox
-ms- trident渲染引擎 IE
-o- opeck渲染引擎 opera
动画、过渡、background-size 都需要加前缀
eg: 动画
@-webkit-keyframes name{ 0%{动画开始的css样式;} 100%{动画结束的css样式;} } -webkit-animation:name 8s fite lear;
过渡:
div.box{ bottom:-40px;<br> -webkit-transition:all .3s ease--out 0s; }
注:过渡不兼容IE8-,可以用JS动画实现
background-size 同样也不支持IE8,可以考虑用img
15.渐变
解决方案:
filter: progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColorStr=#35FEA1,endColorStr=#6E9DFF); /IE 6 7 8/ background: -ms-lear-gradient(, #35FEA1, #6E9DFF);/ IE 10 / background:-moz-lear-gradient(, #35FEA1, #6E9DFF); /火狐/ background:-webkit-gradient(lear, 0% 0%, 0% 100%,from(#35FEA1), to(#6E9DFF));/谷歌/ background: -webkit-gradient(lear, 0% 0%, 0% 100%,from(#35FEA1), to(#6E9DFF));/ Safari 4-5, Chrome 1-9/ background: -webkit-lear-gradient(, #35FEA1, #6E9DFF);/Safari5.1 Chrome 10+/ background: -o-lear-gradient(, #35FEA1, #6E9DFF);/Opera 11.10+/
16.PIE.htc 可以实现很多css3属性在IE下的兼容性 如:圆角、阴影、渐变
(1) 圆角 border-radius
.signBtn{ height: 40px; background-color:#08BCD2; color: #fff; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; behavior: url(css/PIE.htc); }
(2)阴影 box-shadow
.box{ width:200px; height:200px; -webkit-box-shadow:1px 0 10px; -moz-box-shadow:1px 0 10px; box-shadow: 1px 0 10px; background-color: #fff; behavior: url(css/PIE.htc);/IE边框阴影/ }
(3)背景透明rgba
.box{ background-color:rgba(12, 154, 171, 0.29); behavior: url(css/PIE.htc); -pie-background:rgba(12, 154, 171, 0.29); }
(4)渐变
.box{ width:200px; height:400px; background:-webkit-gradient(lear, 0 0, 0 bottom, from(#9F9), to(#393)); background:-moz-lear-gradient(#9F9, #393); -pie-background:lear-gradient(#9F9, #393); behavior:url(pie.htc); }
注:PIE.htc文件路径相对是相对于css文件,并非html文件,以上例子是将PIE.htc文件放在与css样式文件同一个文件夹css内,而对应的html问价与css文件夹同级
17.JS实现点击跳转到指定位置
$(".arraw-bt").click(function(){ var scroll_offset = $("#section").offset(); console.log(scroll_offset); $("body,html").animate({//如果只写body,只被chrome支持 只被chrome支持 Firefox和ie不支持 "scrollTop":scroll_offset. },0);//此处0写上会一下跳转到指定位置,若不写会有过渡效果
网站设计
- 静宁会SEO的网站建设公司:全面提升您的网络影
- 提升在线业务的关键:选择最佳的丽水网站建设
- 浙江网站优化发展潜力如何
- 井研专业的网站建设公司:打造您的在线品牌
- 灵山SEO网站建设公司:提升您的在线业务表现
- 蒙城网站建设优化公司:提升您网站表现的理想
- 阳谷企业网站优化:提升线上业务力的关键
- 樟树专业的网站建设公司:打造您在线业务的坚
- 通河百度SEO排名的策略与技巧
- 重庆百度快照排名如何进行精准的客户引流
- 重庆百度快照排名
- 常宁便宜的建站公司:助您轻松打造在线业务
- 巫溪百度网站优化:提升网站曝光率与流量的关
- 湖北整站优化怎么做才能放大客户需求
- 闸北网站建设多少钱?全面解析与预算规划
- 辽宁企业网站优化怎么做电话营销