【问题标题】:margin and width issue in Google ChromeGoogle Chrome 中的边距和宽度问题
【发布时间】:2017-10-26 11:39:43
【问题描述】:

我正在设置我的 div 的 marginwidth,所有 marginwidth 在 Firefox 和 Internet Explorer 中都可以正常显示。但是,谷歌浏览器无法正常工作。 如果我在 Chrome 中检查页面并调整我的margin,那么它会显示效果,但如果我更新我的 CSS,它就不起作用。

我也在使用-webkit-margin-start: 44px;,但没有任何效果。

我的 CSS 如下:-

#main {
  position:relative;
  width:1200px !important;
  min-height:800px;
  margin:44px auto;
  top: 7px;
  left: 2px;
  -webkit-margin-start: 44px;             
}

任何建议,如果我声明保证金,它也不适用于@media screen and (-webkit-min-device-pixel-ratio:0) { ...

屏幕截图如下:-

对于火狐

提前致谢。

chrome 版本:62.0.3202.62

【问题讨论】:

  • 更新css后,您是否尝试清除chrome中的缓存?
  • 你使用 margin:44px auto 这意味着 margin-top:44px margin-right:auto margin-bottom:44px margin-left:auto 。但是-webkit-margin-start:44px指的是margin-left
  • 你能提供一个minimal reproducible example 来证明这个问题吗?
  • @MihaiT 谢谢,但是如何参考谷歌浏览器的margin-top。

标签: css google-chrome cross-browser


【解决方案1】:

正如我在评论中所说,您使用 margin:44px auto 表示 margin-top:44px margin-right:auto margin-bottom:44px margin-left:auto 。但是-webkit-margin-start:44px指的是margin-left

margin-top-webkit-margin-before。但这主要是指文本边距,它取决于写作模式、方向和文本方向,如您在此处看到的 margin dev moz 或者您可以搜索类似的问题

您的代码似乎可以工作(见下面的 sn-p)。我看到的唯一问题是您使用位置和边距。 (上,左+边距)。我建议你要么使用位置要么边距。例如,不要使用top:7px,而是使用margin:51px auto 44px(如果你想保持下边距为44px)。

没有您的代码,我们无能为力。如果问题仍然存在,请添加一个可以复制您的问题的有效 sn-p

如前所述,我将webkit-margin-start 下方的代码更改为webkit-margin-before

#main {
  position:relative;
  width:1200px !important;
  min-height:800px;
  margin:44px auto;
  top: 7px;
  left: 2px;
  -webkit-margin-before: 44px;     
  background:red;
}
body { margin:0}
<div id="main">

</div>

【讨论】:

  • 感谢您的回复,今天我检查了问题不仅在于边距或高度,还在于整个 css 文件,例如。光标形状在 chrome 中没有改变。 div的颜色在chrome中也没有影响..
  • @speedyraz 好像你有一个问题,如果没有你的任何具体信息,我们无法解决
  • 我编辑了我的问题,css文件是一样的,虽然你的代码sn-p在两个浏览器中都能正常工作,但在chrome中没有任何作用。
猜你喜欢
  • 1970-01-01
  • 2014-01-25
  • 2014-10-13
  • 2011-06-01
  • 2012-07-31
  • 1970-01-01
  • 1970-01-01
  • 2011-07-04
  • 1970-01-01
相关资源
最近更新 更多