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 tag is used in <table> to create table header cell?
<thead> <th> <td>
<table><tr>
  <th>Title 1</th>
  <th>Title 2</th>
</tr></table>
Which CSS property sets the distance between lines?
line-height word-spacing margin
.some_class {
  line-height: 150%;
}
Which function opens a new browser window.
alert() confirm() open()
document.getElementById("id_button").onclick = function(){
  window.open("http://coursesweb.net/");
}
Indicate the PHP function that returns an array with names of the files and folders inside a directory.
mkdir() scandir() readdir()
$ar_dir = scandir("dir_name");
var_export($ar_dir);
Center Fiixed and Absolute element

Last accessed pages

  1. PHP Simple HTML DOM Parser (5823)
  2. PHP MySQL - SELECT, ORDER BY (8642)
  3. Register and show online users and visitors (15612)
  4. Clear Canvas Context (2829)
  5. JavaScript code and PHP (14415)

Popular pages this month

  1. Qwop (4094)
  2. Bubbles3 (3536)
  3. Butterfly Kyodai (2503)
  4. Zuma Deluxe (2305)
  5. Backgammon (1198)