To can center a fixed or absolute positioned element (Div or other block element), set the right and left CSS properties to 0, and then margin-left and margin-right to auto, as if you were centering a static positioned element.
- Example, centering a fixed Div:
<style type="text/css">
#divid {
  position: fixed;
  /* center the element */
  right: 0;
  left: 0;
  margin-right: auto;
  margin-left: auto;
  /* give it dimensions */
  min-height: 8em;
  width: 90%;
  background: #dafeda;
}
</style>

<div id="divid">http://CoursesWeb.net/</div>
- Example, centering an absolute positioned Div (the parent element must have: position: relative):
<style type="text/css">
#parent{
 position:relative;
 height:8.5em;
}
#divid {
  position: absolute;
  /* center the element */
  right: 0;
  left: 0;
  margin-right: auto;
  margin-left: auto;
  /* give it dimensions */
  min-height: 8em;
  width: 90%;
  background: #dafeda;
}
</style>

<div id="parent">
  <div id="divid">http://www.MarPlo.net/jocuri/</div>
</div>
Demo:
http://CoursesWeb.net/

Daily Test with Code Example

HTML
CSS
JavaScript
PHP-MySQL
Which meta tag provides a short description of the page?
<meta content="..."> <meta description="..."> <meta http-equiv="...">
<meta name="description" content="70-160 characters that describes the content of the page" />
Which CSS property is used to stop the wrapping effect of the "float"?
clear text-align position
#some_id {
  clear: both;
}
Click on the method which gets an array with all the elements in the document that have a specified tag name.
getElementsByName() getElementById() getElementsByTagName()
var divs = document.getElementsByTagName("div");
var nr_divs = divs.length;
alert(nr_divs);
Indicate the PHP function which returns the number of elements in array.
is_array() count() strlen()
$arr = array(7, 8, "abc", 10);
$nri = count($arr);
echo $nri;        // 4
Center Fiixed and Absolute element

Last accessed pages

  1. Ajax-PHP Chat Script (33166)
  2. SHA512 Encrypt hash in JavaScript (7619)
  3. Qwop (55289)
  4. Bind Tool and Control Points (2616)
  5. My New Room 2 (165)

Popular pages this month

  1. Qwop (10207)
  2. Drag Racer V3 (6099)
  3. Flash Games - Free online Games (2084)
  4. List with All the Games (2030)
  5. Bubbles3 (1892)