vertical alignment of div inside another - issue

≡放荡痞女 提交于 2019-12-13 02:31:32

问题


I originally had floating divs and i wanted content inside these floats to be vertically aligned.

This was giving me troubles so i had to remove floats.

I came around this fiddle referred in this post.

And used the fiddle to get desired layout. But i am facing troubles vertically aligning divs.

I tried,

vertical-align:middle;
display:table-cell;

For parent containers and

display: inline-block;

for child contents.

1) In this fiddle. I want the right to be vertically aligned inside right-container.

To say in other words. I want to have two divs vertically aligned inside a main div, and divs inside each of two divs need to be vertically alined.

2) How can i achieve the vertical alignment inside the floats? So i may not change my original layout. Say in the fiddle right and left are floats.

Need some pointers.

Edit:

This might be simpler with tables. But i am looking for div based solutions.


回答1:


Is that what you want?

Added: <div id="right" style="display:table-cell;vertical-align:middle;"> RIGHT </div>

jsFiddle update: http://jsfiddle.net/5vpA3/157/



来源:https://stackoverflow.com/questions/13222687/vertical-alignment-of-div-inside-another-issue

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!