Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1039
  • Last Modified:

Center Flash object in center of screen

Hi,

I have a flash object named index.swf and what I want is for it to appear in the bang center of the screen within a webpage (HTML) I have searched the internet and on here but cannot get one that works :/
The size of my flash is 720 x 540.

Thanks,
0
jasocke2
Asked:
jasocke2
  • 2
  • 2
2 Solutions
 
ErwindeVriesCommented:
Have u tried simple <Center>%here comes ur flash vid%</center>

Can i see the code in which it should be centered?
0
 
mreuringCommented:
The quick and dirty approach (since for the life of me I can't recall how to fix the edge cases) is to position the flash absolutely to 50% by 50% of the screen (this places the top-left corner at this position... And subsequently moving the flash by negative margin, half its' height and half its' width up and left, thus placing the center of the flash at the center of the screen.
I've attached a simple html example (assuming the use of swfobject.js to insert the flash into the correct div).
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
	<title>Center object</title>
	<style type="text/css" media="screen">
		html, body {
			margin: 0;
			padding: 0;
			width: 100%;
			height: 100%;
			background: blue;
		}
		#myFlash {
			width: 500px;
			height: 300px;
			margin-top: -150px;
			margin-left: -250px;
			position: absolute;
			top: 50%;
			left: 50%;
			background: rgba(32, 32, 32, 0.5)
		}
	</style>
</head>
<body>
	<div id="myFlash"><p>This is what you see if no flash is loading :)</p></div>
</body>
</html>

Open in new window

0
 
ErwindeVriesCommented:
It can go way quicker and much dirtier.

<html>
<head>
<title>flash vid</title>
</head>
<body>
<br>
<br>
<br>
<br>
<br>
<br>
<center>
<object width="550" height="400">
<param name="movie" value="index.swf">
<embed src="index.swf" width="550" height="400">
</embed>
</object>
</center>
</body>
</html>

Open in new window

0
 
mreuringCommented:
@Erwin
The least you could have done is going with a centered table and vertical align on the table-cell. As it is you're only centering horizontally which makes your solution less functional, although admittedly easier to implement.
0
 
jasocke2Author Commented:
Both Worked great thanks,
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now