PDA

View Full Version : how to center flash vertically using swfobject 2?


kangaroach
12-24-2008, 10:27 PM
how to center flash vertically using swfobject 2?

here is the html code, that right now centers the movie only horizontally. How to center it vertically?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Christian FM</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
swfobject.registerObject("myId", "10.0.0", "expressInstall.swf");
</script>
</head>
<body>
<div style="text-align: center;">
<object id="myId" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="816" height="616">
<param name="movie" value="christianfm.swf" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="christianfm.swf" width="816" height="616">
<!--<![endif]-->
<div>
<h1>Alternative content</h1>
<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
</div>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</div>
</body>
</html>


thanks for any help!

tBeck
12-25-2008, 02:37 AM
surround the object tag with a div tag (like you have), and give it an ID/CLASS. Then use CSS to vertically center the object.

EDIT:

you can use the following CSS to vertically/horizontally align the object to the page:



<style type="text/css" media="all">
.center {
position:absolute;
top:0px;
right:0px;
bottom:0px;
left:0px;
width:50%;
height:50%;
margin:auto;
}
</style>