Google Chrome中的边距和宽度问题

时间:2017-10-26 11:39:43

标签: css google-chrome cross-browser

我正在设置我的div marginwidth,所有marginwidth在Firefox和Internet Explorer中都正常显示。但是,Google Chrome无法正常运行。 如果我在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) {中也无效......

屏幕截图如下: - enter image description here代表chrome

for Firefox enter image description here

提前致谢。

chrome版本:62.0.3202.62

1 个答案:

答案 0 :(得分:0)

正如我在评论中所说,您使用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所见,或者您可以搜索SO以寻找类似的问题

您的代码似乎有效(请参阅下面的代码段)。我看到的唯一问题是你使用位置和保证金。 (上,左+边距)。我建议您使用保证金。例如,请勿使用top:7px,而是使用margin:51px auto 44px(如果您想将底部边距保持为44px)。

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

我更改了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>
&#13;
&#13;
&#13;

相关问题