Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

align right in dynamicly sized div

Status
Not open for further replies.

seantuk

Programmer
Mar 22, 2005
62
GB
i have a page with three things on it. at the top is a ul; bellow that a swf, of an unknown width; at the bottom is a paragraph of text.

all of the content needs to be centered down the page, in a column as wide as the swf. the ul needs to align right (so it sits just above the top right corner of the swf). the paragraph of text needs to be directly under the swf, and exactly as wide.

what i need to know, is how can i create a div, that surrounds everything, and is exactly as wide as the swf - so i can use things like align right and fully justified text to create a column of content.

if you don't get what i mean, please ask.
 
seantuk said:
how can i create a div, that surrounds everything, and is exactly as wide as the swf
Code:
<div style="width: [widthofswf]px; margin: 0 auto;">
 all your content
</div>
 
i don't know the width of the swf. ideally, i'd like a solution that works for any width
 
If you use [tt]width: auto;[/tt], div will be as wide as the widest element inside it. I am not sure however if the margins will work in that case to center it. They actually should, but who knows what browser support for that is.
 
actually i think 'auto' fills up to the size of its parent. let me just check...


..yes. sorry. it's a shame, that'd be an elegent and simple solution.


i can do it with a table set to a small width (but not zero), but i'd rather not use tables for styling if i can help it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top