Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 and vertical-align? Fixed now?

I come from the world, and have been looking at resources on google about doing multiple wrappers to vertically align content -- however it seems like it's really ugly.

Is there an easier way now with HTML5? Is there some sort of implementation that uses something like the HBox/VBox mentality? I saw there are examples for non-ie browsers -- is there a compliant way?

How the heck does anyone in their right mind do HTML now? It's a mess!

//// EDIT

I've finally figured out how to vertically align an entire box over a screen, how I'm figuring out how to vertically center list items.

I've tried two methods to align this html:

<nav>
    <ul>
        <li><a href="#!/home">Home</a></li>
        <li><a href="#!/link1">Link #1</a></li>
    </ul>
</nav>

one using display:inline, the other using float:left (within a container). When using inline, it seems the list items ignore the height: css, and when using float:, the links within the li do not vertically align. Do I need to place div's within the li's to get them to vertically center as well?

like image 857
ansiart Avatar asked Aug 25 '10 17:08

ansiart


People also ask

Is vertical-align deprecated?

Deprecated as an attribute Occasionally you will see “valign” used on table cells to accomplish vertical alignment. e.g. <td valign=top> . It should be noted that this attribute is deprecated and should not be used.

How do I vertically center a div element?

Using the Line-Height Property In most cases, you can also center text vertically in a div by setting the line-height property with a value that is equal to the container element's height. Let's create the same div element with a yellow border around it as above.

How do I vertically align text in a div?

Answer: Use the CSS line-height property Suppose you have a div element with the height of 50px and you have placed some link inside the div that you want to align vertically center. The simplest way to do it is — just apply the line-height property with value equal to the height of div which is 50px .


1 Answers

Why don't you try using display: box with box-align:center, this is CSS3, so not every browser supports it yet (only Chrome, FireFox, and Safari)

http://www.w3schools.com/cssref/css3_pr_box-align.asp

like image 87
Goodwine Avatar answered Nov 04 '22 10:11

Goodwine