Groups | Blog | Home
all groups > macromedia flash sitedesign > may 2005 >

macromedia flash sitedesign : How to center a swf within a DIV tag??


Skatestick
5/26/2005 12:00:00 AM
Hi, I want a swf file tonto a website with DIV tags but I want the swf to be
centered no matter what the resolution is. This is what I have:

<html>

<head>

<title>Televisie</title>

<style>
#example{
position:absolute;
top:20px;
left:20px; <-------- ??? Should that be diffirent or be left out?
width:800px;
height:600px;

}

</style>

</head>

<body>

<div align="center" id="example">

<embed src="example.swf" wmode="transparent" width="800" height="600">

</div>

</body>

Please help. Thanks

</html>
El Jay Kay
5/29/2005 4:41:30 AM
Hi -
So you really need this to be 20px from the top and left of the browser window?
If not, I'd avoid using absolute positioning, since it can be rather
problematic.
The quick answer is -
margin{
0 auto;}
Which leaves no margin at the top and bottom, then lets the browser det. the L
& R. This will center anything 90% of the time...

An alternative to absol. posit. would be to set the div's text-align:left; to
move any content to the left side. Be sure you've specified the width and
margins of the div, then you really shouldn't need to mess with the .swf's tags.
If needed, you can do -
#example object, #example embed{
styles go here;}

Good luck,
El
AddThis Social Bookmark Button