4
我想要一个相邻的文本输入和按钮完美排列。我专门针对Chrome,但如果它适用于所有现代浏览器,它会更加出色。包含日文文本时CSS - 按钮和文本输入不对齐
This answer差不多工作,虽然它仍然没有在Firefox排队。但是,如果我在按钮中输入日文文本,即使我在文本输入中输入日文文本,高度也会略微偏移。
div {
font-family: 'Hiragino Kaku Gothic ProN', 'ヒラギノ角ゴ ProN W3', Meiryo, メイリオ, Osaka, 'MS PGothic', arial, helvetica, sans-serif;
padding: 0.5em;
}
label, input, button {
font-size: inherit;
height: 1.2em;
padding: 0.2em;
margin: 0.1em 0.1em;
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box;
box-sizing: content-box;
}
<form action="#" method="post">
<div>
<input type="text" name="something" id="something" value="This works" />
<button>just fine</button>
</div>
</form>
<form action="#" method="post">
<div>
<input type="text" name="something" id="something" value="あ This" />
<button>あ doesn't line up!</button>
</div>
</form>
(JSFiddle) 在Chrome 54.0.2840.99,结果在此:
有趣的是,他们完美地排队在IE 11
有没有一种将Chrome浏览器完美对齐的方式,最好还可以在Firefox和Safari中进行对齐。轻微的差异让我发疯。
尝试添加'垂直对齐:中间;'在CSS –
也许减少字体大小咯,只有日本的文字,在按钮? – Stefan