从另一个div垂直对齐到动态高度? [英] Vertically align to a dynamic height from another div?

查看:119
本文介绍了从另一个div垂直对齐到动态高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将一个div垂直对齐到高度动态的相邻div。

I am trying to vertically align one div to the adjacent div which is dynamic in height.

我遇到的大多数方法都要求我知道父div。但是如果你看到我的例子,它是驱动整个部分的高度的正确div。

Most methods I have come across require me to know the height of the parent div. But if you see my example, it is the "right" div that drives the height of the entire section.

我试图让divleft的文本垂直居中到右边的div。 父div也没有固定的高度。

I am trying to have the text from div "left" appear vertically centred to the div on the right. The "parent" div does not have a fixed height either.

我最好用CSS做什么?

How can I do this, ideally with CSS?

感谢。

我的示例:

http://jsfiddle.net/halogenmobile/McVAE/9/

推荐答案

有时CSS盒子模型不适用于此,所以你可以恢复到好的旧式表模型。

Sometimes CSS's box model doesn't work for this, so you can revert to the good old fashioned table model. (Not to say you have to adjust your markup).

查看 display:table display:table-cell vertical-align:middle

我更新了小提琴: http://jsfiddle.net/McVAE/18/

这篇关于从另一个div垂直对齐到动态高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆