是否有一个类似于 if IE hack 的 if Firefox
正如我一直在学习的那样,我养成了只在 chrome 中做事的坏习惯。最近,我开始研究我在其他浏览器中制作的东西;太糟糕了。我注意到firefox中的定位有点不同,safari基本相同,而IE则是一团糟。现在我只专注于让 Firefox 中的东西正常工作。是否有一种 if Firefox
条件语句?
As I have been learning, I have developed a bad habit of only doing things in chrome. More recently I have started looking at stuff I make in other browsers; it sucks. I have noticed that the positioning in firefox is a little different, safari is basically the same, and IE is a hot mess. For now I am just going to focus on getting things to work correctly in firefox. Is there a sort of if Firefox
conditional statement?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在基于 Mozilla 的浏览器(如 Firefox)中,没有与 IE 条件注释 等效的功能。
根据您的服务器端平台(如果有),您可以选择嗅探浏览器类型并有条件地包含不同的样式表。当然,您希望尽可能避免这种情况。通常,通过修复一些问题,使其在所有浏览器上一致工作,您最终会得到更好、更强大的网站,从长远来看,这可能会节省您的时间。
关于 CSS 差异,您可能会考虑从重置 CSS 开始,例如 Joe 的回答中建议的 CSS,以提供统一的基线。
关于浏览器之间 HTML 和其他功能的标准化,您可能需要查看 modernizer。
There is no equivalent to IE Conditional Comments in Mozilla based browsers like Firefox.
Depending on your server-side platform (if any), you could elect to sniff the browser type and conditionally include different style-sheets. Of course, you want to avoid this as much as possible. Usually by fixing things to work consistently across all browsers, you end up with better, more robust, site that will probably save you time in the long run.
Regarding CSS differences, you might consider starting with a reset CSS, such as the one suggested in Joe's answer, to provide a uniform baseline.
Regarding standardization of HTML and other features between the browsers, you might want to check out modernizer.
我发现这个脚本可以解决很多问题(当然不包括 IE) reset.css
I find this script will solve a lot of quirks (minus IE of course) reset.css