对齐中间问题 [英] align-middle question

查看:113
本文介绍了对齐中间问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 vertical-align:middle; 的工作方式有什么误解?

What is my misunderstanding about the way that vertical-align:middle; works?

http://jsfiddle.net/D6RwZ/ )一些代码,我希望垂直对齐一个红色的矩形

I have posted (http://jsfiddle.net/D6RwZ/) some code which I would expect to vertically align a red rectangle in a blue rectangle, but it doesn't look like that.

推荐答案

垂直对齐仅适用于内联图像和显示:表单元格。

Vertical-align only works on inline images and display: table-cell.

我使用了这个解决方案几次,它的工作相当好,但需要一些工作。如果你使用固定大小的元素位置绝对是迄今为止最简单的。动态大小的元素和垂直居中可能非常棘手,很多浏览器的怪癖处理。

I've used this solution a few times and it works quite well but takes some work. If you're working with fixed size elements position absolute is by far the simplest. Dynamic sized elements and vertical centering can be very tricky, lots of browser quirks to deal with.

这篇关于对齐中间问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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