我在一个页面上有一个div,其他浏览器上的按钮放置得很整齐,但在chrome上,它们正在掉落。 我知道 IE 7 的显式黑客攻击,例如 *Margin,但不知道 chrome。有没有办法在 css 中定义。 我不想用条件语句来处理这个问题。我需要明确提及负像素的边距,以便 chrome 将按钮拉起。
最佳答案
此 jQuery 应将 class="chrome"添加到文档的 html 元素。
$(document).ready(function(){
if (navigator.userAgent.indexOf('Mac OS X') != -1) {
if (/chrome/.test(navigator.userAgent.toLowerCase())) { $('html').addClass('chrome'); }
} else {
if (/chrome/.test(navigator.userAgent.toLowerCase())) { $('html').addClass('chrome'); }
}
});
然后您可以像这样定位 div:
.div {
margin-bottom: 10px;
}
html.chrome .div {
margin-bottom: 20px;
}
关于asp.net - 在 chrome 中明确定义 Margin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20611524/