Re: [问题] 上下置中

楼主: eight0 (欸XD)   2014-08-22 20:25:55
※ 引述《yshlptt (小y)》之铭言:
: 一、使用绝对位置定位
: 把 container 元素设为 position: relative(或依需求设定 absolute)
: ...
这个真炫,我也是第一次看到。以前也有种常见的做法是把 parent 设成
relative,child 设 absolute,加上 top 与 margin-top 调位置。
http://jsbin.com/notifucigedo/7/edit?html,css,output
缺点是要知道 child 的高度。
这个方法好像是之前在板上看到的,用空的行区块原素设 height: 100% 来填满高度。
http://jsbin.com/peqilugomemi/1/edit?html,css,output
缺点就是要处理空白符,网络上也满多讨论
http://css-tricks.com/fighting-the-space-between-inline-block-elements/
个人觉得目前最好的做法还是 display: table-cell,和 Bootstrap 的
Grid system 也能很好的配合。

Links booklink

Contact Us: admin [ a t ] ucptt.com