5

How can I add vertical-align: middle to elements using PureCSS, from YUI?

I have three elements with have the same height, and I want that, "inside", they have vertical-align: middle.

=> Check jsfiddle: http://jsfiddle.net/kn88b/1/

The closest I get was with display: table; width: 100%, but this BUGs the "mobile version", so I want a solution for all versions (tablet/desktop/mobile).

enter image description here

4

2 回答 2

6

使用弹性盒!这是我在 Chrome 中测试过的 JSFiddle。

http://jsfiddle.net/kn88b/6/

我指定display: flex.a,.b,.c指定margin: auto.inside

要制作这个跨浏览器,只需确保使用所有供应商前缀。

您可以在此处了解有关 flexbox 的更多信息:http: //coding.smashingmagazine.com/2013/05/22/centering-elements-with-flexbox/

于 2014-04-07T06:59:32.577 回答
1

你去:http: //jsfiddle.net/kn88b/3/。用于display:table父元素和display:table-cell; vertical-align:middle;子内容

于 2014-04-07T06:37:40.880 回答