【发布时间】:2014-10-02 05:30:29
【问题描述】:
我遇到了一个非常简单的代码问题。
Chrome 似乎忽略了我正在使用的否定 margin-bottom。在 IE11 中按预期工作。
IE 11
铬 38
我只想对齐它们。我知道我可以使用更多代码来实现,但我想知道我是否期望 margin-bottom 的工作与它应该工作的不同:
<div id="main">
<select>
<option value="2014">2014</option>
</select>
<button></button>
<select id="AmbientesSelect">
<option value="TEST">TESTE</option>
</select>
<button></button>
</div>
这是css:
#main {
background-color:red;
}
#main button {
width: 28px;
height: 23px;
border: solid 1px #ccc;
margin-bottom: -7px;
}
现场复现:http://jsfiddle.net/v4bd7xjy/2/
我搜索了一些问题,但它们太具体或太不同了。其中一些:
Why Chrome doesn't respect the margin properly?
Negative margin-bottom rendering not correctly in Chrome
How do negative margins in CSS work and why is (margin-top:-5 != margin-bottom:5)?
编辑
如果那件事我填写了一份关于 Chromium 项目的 bug 报告。
【问题讨论】:
-
我会使用垂直对齐和浮动来统一对齐,根据需要删除任何填充和边距。例如:jsfiddle.net/j08691/gkndebpn
-
我同意@j08691,或者你可以试试 position:relative;顶部:7px;把它们往下推一点。
-
@j08691 好吧,它奏效了。但是
margin-bottom应该这样工作,对吧?
标签: html css google-chrome margin