Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

你会如何解决特定浏览器的样式问题? #50

Open
zhuguly-zz opened this issue Jul 4, 2020 · 0 comments
Open

你会如何解决特定浏览器的样式问题? #50

zhuguly-zz opened this issue Jul 4, 2020 · 0 comments

Comments

@zhuguly-zz
Copy link
Owner

  • 针对IE9及更老版本的浏览器可以使用IE条件注释的方法:
<!--[if IE 6]>
<p>You are using Internet Explorer 6.</p> <![endif]-->
<!--[if !IE]><!--> <script>alert(1);</script> <!--<![endif]-->
<!--[if IE 8]>
<link href="ie8only.css" rel="stylesheet"> <![endif]-->
  • 可以针对不同浏览器的bug使用CSS Hack:
.box {
  color: red;
  _color: blue; /* 仅ie6能识别 */
  *color: pink; /* ie67能识别 */
}
.clearfix::after {
  content: '';
  display: block;
  clear: both;
}
.clearfix {
  *zoom: 1; /* 仅对ie67有效 */
}
.target {
  display: inline-block;
  *display: inline;
  *zoom: 1;
}
  • 通过js让老的浏览器支持HTML5
<!--[if lt IE 9]>
<script src="https://github.com/aFarkas/html5shiv/dist/html5shiv.js"></script>/* 让ie6-9支持Html5标签 */
<script src="https://github.com/scottjehl/Respond/dest/respond.min.js"></script>/* 让ie6-8支持媒体查询 */
<![endif]-->

其他相似问题:
如何为有功能限制的浏览器提供网页?
浏览器Hack有哪些方法?

题目来自饥人谷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant