Jump to content

Center Vertical Positioning


kitster79

Recommended Posts

"The vertical-align property sets the vertical alignment of an element".... http://www.w3schools.com/Css/pr_pos_vertical-align.asp

 

eg. vertical-align:middle;

 

or, It seems to me that you could give each link a class such as one_line and two_lines. Set the line-height and then use padding to adjust each class? Just my two cents, but I'm still very new to this. I'm sure others will have a more concrete solution, but the vertical-align property came straight from w3schools.com.

 

Mark

Link to comment
Share on other sites

I don't think I've ever used vertical-align: middle except as a test and I don't remember seeing it used in other websites either. I prefer to use margin-top or padding-top with a class.

 

w3schools says that vertical-align is used relative to a baseline:-

Align the baseline of the element with the baseline of the parent element. This is default

 

what this usually means is that if you have a image inline with text, the image will align its bottom with the bottom of the text so that it "sticks up" but if you use vertical-align: middle, the image will align its middle with the middle of the line of text.

See http://www.wickham43.net/generaladvice.php#textalignvert

 

This might not work where you use it just for one line of text, but you could try.

Link to comment
Share on other sites

Thanks Eric, but that does not solve the problem for the lines of text that have 2 lines, right?

 

no, your right, it doesn't. Did you get it centered though? It looks like you did! There is also the floating an extra container above the text method, like I did here... http://www.visibilityinherit.com/code/body-scroller-demo.php

 

But, it seems like you need a method which will cater for a varible height. Paul, has a demo somewhere explaining that. May want to try googling "pmob varible height vertical centering".

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...