/ Published in: ActionScript 3
URL: http://www.adrianparr.com/flash/center_flash_movie_in_browser/index.html
This CSS code is useful if you want to centre your Flash Movie in the browser horizontally and vertically.
Expand |
Embed | Plain Text
<!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" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Centre Flash Movie in Browser</title> <script src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js" type="text/javascript"></script> <script type="text/javascript"> var flashvars = { }; var params = { menu: "false", scale: "noScale", allowFullscreen: "true", allowScriptAccess: "always", allowNetworking: "all", bgcolor: "#ffffff", base: "swf/" }; var attributes = { id:"flashMovie" }; swfobject.embedSWF("swf/flash_movie.swf", "flashMovie", "550", "400", "9.0.0", "swf/expressinstall.swf", flashvars, params, attributes); </script> <style type="text/css"> html, body { height: 100%; /* This value has to be set */ margin: 0; padding: 0; } div#shim { float: left; visibility: hidden; width: 100%; height: 50%; margin-top: -200px; /* This has to be half the height of the element you want to center */ } div#wrapper { clear: both; /* This value has to be set */ width: 550px; height: 400px; /* Need to specify a height */ background: #f5f5f5; margin: 0 auto; /* This centres horizontally */ } </style> </head> <body> <div id="shim"></div> <div id="wrapper"> <div id="flashMovie"> <a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adrianparr.com/images/160x41_Get_Flash_Player.jpg" alt="Get Adobe Flash player" border="0" width="160" height="41" /></a> </div> </div> </body> </html>
You need to login to post a comment.
