ie8下的兼容问题处理:背景透明,css3圆角,css3和jquery支持部分css3选择器(例如:nth-child),支持html5的语义化标签,媒体查询@media等。javascript
在html页面头部<head>优先加载ie8须要的插件,由于部分插件须要依赖jquery,因此jquery须要最早加载。而后用IE的条件注释添加须要的脚本css
若是是其余的样式.css就添加在<head>里面的全局global.css后面html
<head>html5
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>车险保费计算</title> <script src="../../../public/js/jquery-1.11.2.min.js"></script> <!--[if lte IE 8]> <script type="text/javascript" src="../../../public/js/html5.js"></script> <script type="text/javascript" src="../../../public/js/respond.min.js"></script> <script type="text/javascript" src="../../../public/js/selectivizr-min.js"></script> <![endif]--> <!--[if IE 6]> <script type="text/javascript" src="../../../public/js/DD_belatedPNG_0.0.8a.min.js"></script> <script> DD_belatedPNG.fix('*'); </script> <![endif]--> <!--全局css--> <link rel="stylesheet" type="text/css" href="../../../public/css/global.css"/> </head>
若是是其余的插件和逻辑js就添加在 </body>的上方。注意顺序,插件js优先添加。java
<script src="../../../public/js/jquery.easydropdown.js"></script> <!--全局js--> <script src="../../../public/js/global.js"></script> <!--逻辑js--> <script src="../js/calcPrice.js"></script> </body> </html>
只要如上添加插件js就能够在ie8下使用css3和jquery css3选择器nth-child,html5语义化标签,如:section articel,媒体查询@media等。jquery
圆角border-radiuscss3
直接将pie.htc文件放在项目结构里,如图1的红色块1web
如图1的红色块2 calcPrice.html添加的样式如图1的红色块3calcPrice.css里面的样式用到圆角或阴影,需在后面添加behavior: url(../../../public/css/PIE.htc);浏览器
关键来了,behavior后面的url路径不是css相对pie,这个和咱们平时的background-image使用不同。这个路径是html相对的pie路径。你也能够理解成calcPrice.html这个页面添加图1红色块1上面的global.css 的路径就是behavior: url(../../../public/css/PIE.htc)的正确路径了,由于pie文件和global.css 文件在同一个目录下。ui
盒子阴影:
box-shadow: 1px 1px 1px #dedede; -moz-box-shadow: 1px 1px 1px #dedede; -webkit-box-shadow: 1px 1px 1px #dedede; behavior: url(../../../public/css/PIE.htc);
圆角
border-radius: 10px; -webkit-border-radius: 10px; -moz-border-radius: 10px; behavior: url(../../../public/css/PIE.htc);
ie8背景图片没生效?
例子: background: url(../images/carInfo.png)no-repeat 0 0; 以上这样的路径是正确的,在chrom下彻底没问题,为何到了ie8,背景图就显示不了? 解决办法很简单 background: url(../images/carInfo.png) no-repeat 0 0; 在url()后面加上两个空格就能够了。
娇气的ie8,按照上面使用的pie.htc的圆角和盒子阴影,发现元素隐藏不见了!!!!
解决办法:在须要用圆角和阴影的元素样式上加上position:relative; 就能够了。
ie8背景透明opacity
在ie8下背景透明而透明层上没文字或图片内容的时候,能够在opacity=0;下一行直接添加 filter:Alpha(opacity=0);
可是透明的背景上有内容的时候,在ie8只上面加了filter:Alpha,是否是以为就像你大冬天在浴室里带着眼镜洗热水澡看到的情景。。。。。眼前一片朦胧哇~~~
假设咱们须要设置下面的div背景透明而文字不透明 <div class=" coverModal"> <!--用于定位 --> <div class="coverBg "> <!--背景透明的块 --> <div class="coverCon">我是文字,我不想被透明啊~</div> <!--主体内容 --> </div> </div>
/*遮盖层公共样式*/ .coverModal{ display: none; position: fixed; width: 100%; height: 100%; top: 0; margin-left: -6%; z-index: 9999; } .coverBg { height:100%; background-color: rgba(0,0,0,0.5); /* IE九、标准浏览器、IE6和部分IE7内核的浏览器(如QQ浏览器)会读懂 */ } .coverBg .coverCon{ color: #FFFFFF; } @media \0screen\,screen\9 { /* 只支持IE六、七、8 */ .coverBg { background-color:#000000; filter:Alpha(opacity=20); position:static; /* IE六、七、8只能设置position:static(默认属性) ,不然会致使子元素继承Alpha值 */ *zoom:1; /* 激活IE六、7的haslayout属性,让它读懂Alpha */ } .coverBg .coverCon{ position: relative; /* 设置子元素为相对定位,可以让子元素不继承Alpha值 */ } }
background-color:red; background-color:red\0; /* ie 8/9*/ background-color:blue\9\0; /* ie 9*/ /*ie11 css hack*/ @media all and (-ms-high-contrast:none) { *::-ms-backdrop, .class名字 { 里面的样式:样式值;} } /*ie10 css hack*/ @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) { .class名字 { 里面的样式:样式值;} }