Solved

Center Flash object in center of screen

Posted on 2010-09-07
5
1,023 Views
Last Modified: 2012-06-21
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
Comment
Question by:jasocke2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 4

Expert Comment

by:ErwindeVries
ID: 33616560
Have u tried simple <Center>%here comes ur flash vid%</center>

Can i see the code in which it should be centered?
0
 
LVL 17

Accepted Solution

by:
mreuring earned 250 total points
ID: 33616652
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
 
LVL 4

Assisted Solution

by:ErwindeVries
ErwindeVries earned 250 total points
ID: 33617061
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
 
LVL 17

Expert Comment

by:mreuring
ID: 33627626
@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
 

Author Closing Comment

by:jasocke2
ID: 33628269
Both Worked great thanks,
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Change color in a check box 8 32
html5 1 40
Javascript question 8 39
I'm looking for a dynamic length jQuery/javascript currency editor mask? 2 55
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question