看板 Web_Design 關於我們 聯絡資訊
大家好 想請問有一個css float為left的父元素div,在不知道其高度的情況下 有辦法將裡面的元素(比如說是p或是form)垂直水平置中嗎 有爬過相關文章,但是是在知道父元素高度的情況下 例如這篇 https://stackoverflow.com/questions/12168145/vertically-center-content-of-floating-div 那在不知道高度的情況下,是不是就無法將裡面的元素垂直水平置中了呢@@ 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 106.105.118.93 ※ 文章網址: https://www.ptt.cc/bbs/Web_Design/M.1502634100.A.FE0.html
ssadd502227: 改inlineblock align cnter最快 08/14 00:13
xdraculax: flex 08/14 11:55
s25g5d4: display: flex 08/14 20:55
s25g5d4: 然後看情況設定 align-content / align-item / justify- 08/14 20:55
s25g5d4: content 成 center 08/14 20:55
s25g5d4: ^^^^ items 更正 08/14 20:56
aspdoctor: Child {top: 50%; transform: translateY(-50%);} 08/15 23:52
articulation: 謝謝樓上大大們的建議 08/20 20:26
※ 編輯: articulation (106.105.118.25), 08/20/2017 20:54:22
articulation: https://jsfiddle.net/Lf1nfqth/ 這邊有解法 謝謝mi 08/31 13:41
articulation: yabichiku大大的幫忙 08/31 13:42
articulation: https://jsfiddle.net/aud6tnLj/ 這邊是flex版本唷~ 08/31 18:14