@saulssauthorOct 02.2005 — #hmmm... isnt there a simpler way?
like this [code=html]<div style="width:100px;height:100px;padding: 50%;background-color:red" > text or image </div>[/code] this centers the content vertically and horizontally, but it calculates the 50% based on the width and height of the div AND the width and height of the text.
The other code on that page used and innacurate way to calculate the vertical center. (you will notice it when you resize the window to almost the size of the box inside.)
@KravvitzOct 02.2005 — #If there is only one line of text, then you only need text-align:center and vertical-align:middle.
Please provide a link to the page in question.
this centers the content vertically and horizontally, but it calculates the 50% based on the width and height of the div AND the width and height of the text.[/QUOTE] *shrugs* That's the way it works. We can't do anything about it.
The other code on that page used and innacurate way to calculate the vertical center. (you will notice it when you resize the window to almost the size of the box inside.)[/QUOTE] You mean the code from the demo I linked to? It's a rather complicated demo, perhaps you missed part of the necessary code.
notice how it centers it without resizing the table, unlike this (posted previously)
[code=html]<div style="width:100px;height:100px;padding: 50%;background-color:red" > text or image </div>[/code]
it will be for a menu in which im changing the class on different mouse events, so i wanted to keep the content of an item on single divs, nested into another that holds all of them