-2

Possible Duplicate:
Best practice vertical-align center content on div

How can I vertical align center .content for the both squares using same CSS.

Example

Thanks

Community
  • 1
  • 1
Ricardo Rodrigues
  • 2,633
  • 5
  • 29
  • 31

4 Answers4

1

Here's the solution -> http://jsfiddle.net/Sha6m/12/.

You need to add display: table-cell; to the inner .content, set their vertical-align to middle (vertical-align: middle;) and give them the same height and width of their parent .area (100% width and height unfortunately don't work here, so when you alter the .area's height and width, you also have to do it for the .content div).

João Paulo Macedo
  • 15,297
  • 4
  • 31
  • 41
0

style='vertical-align:middle' ..

nimrod
  • 132
  • 1
  • 1
  • 8
0

You're applying display table-cell to the wrong elements. You have to wrap them in a container, and apply display: table cell to that container. Check my example -> http://jsfiddle.net/Sha6m/10/

Sparky
  • 98,165
  • 25
  • 199
  • 285
João Paulo Macedo
  • 15,297
  • 4
  • 31
  • 41
0

When u got a fixed height i would just add a line-height: 100px; and remove your vertical-align and display

jsfiddle modification

Dejan.S
  • 18,571
  • 22
  • 69
  • 112