简体   繁体   English

WebKit内联元素的垂直对齐方式不正确

[英]Incorrect vertical alignment in WebKit of inline elements

I have a small definition list that I would like to center on the page both horizontally and vertically in four columns. 我有一个小的定义列表,我想在页面的水平和垂直方向上以四列为中心。 I have the html -element set to display: table and the body to display: table-cell; 我将html -element设置为display: table和要display: table-cell;body display: table-cell; with vertical-align: middle; vertical-align: middle; .

See this Fiddle . 看到这个小提琴 If you change the font-size on line 27 to 4em; 如果您将第27行的font-size更改为4em;4em; (or anything larger than 1em ), you will see that on Chrome the content jumps to the wrong position, while it was correct before. (或大于1em任何值),您会看到Chrome上的内容跳到了错误的位置,而之前是正确的。 On IE the font-size does not matter, it stays in the correct position either way. 在IE上,字体大小无关紧要,无论哪种方式,它都保持在正确的位置。

If you set the dl to display: block , it works on both browsers as well but I visually need them to be displayed inline. 如果将dl设置为display: block ,那么它也可以在两种浏览器上使用,但是我视觉上需要将它们内联显示。

Am I doing something wrong or is this a bug in Chrome. 我是在做错什么还是Chrome中的错误。 If so, how can I work around it? 如果是这样,我该如何解决?

Add

vertical-align: top;

to your dl. 给你的dl。 Check here http://jsfiddle.net/qVcLE/6/ . 在这里检查http://jsfiddle.net/qVcLE/6/ Unfortunately display: inline; 不幸的是显示:内联; etc causes that type of issues. 等等会导致这类问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM