bootstrap是依赖jquery的,高版本的jquery已经放弃对IE8的支持,因此,jquery的版本要注意一下,引用低版本的,这里引用的是1.12.1。
引用以下两个文件,html5shiv.js是使IE8支持h5的语法,respond.js让IE6-8支持CSS3 Media Query。
官方网站:https://code.google.com/p/html5shiv/
官方网站:http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js
<!--[if lt IE 9]> <script src="js/html5shiv.min.js"></script> <script src="js/respond.min.js"></script> <![endif]-->
【相关教程推荐:bootstrap视频教程】
设置meta标签
<meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1" /> <meta http-equiv="X-UA-Compatible" content="IE=9" />
解决placeholder不生效的问题
<script> $(function(){ if( !('placeholder' in document.createElement('input')) ){ $('input[placeholder],textarea[placeholder]').each(function(){ var that = $(this), text= that.attr('placeholder'); if(that.val()===""){ that.val(text).addClass('placeholder'); } that.focus(function(){ if(that.val()===text){ that.val("").removeClass('placeholder'); } }) .blur(function(){ if(that.val()===""){ that.val(text).addClass('placeholder'); } }) .closest('form').submit(function(){ if(that.val() === text){ that.val(''); } }); }); } }); </script>
至此,基本已经解决boostrap兼容IE8的问题。
更多web开发、web前端课程相关知识,请查阅 HTML中文网 !!
以上就是bootstrap不兼容ie8怎么解决?的详细内容,更多请关注0133技术站其它相关文章!