Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to create a HTML webpage with a table, td, div, any kind of this, fixed and centered (vertical and horizontal) of that size: 1010px of width and 565px of height.

Is there a way to do that without using frames or iframes and that the table, div or anything has a width and height no auto-sizable?

share

migration rejected from serverfault.com Mar 7 at 19:12

This question came from our site for system and network administrators. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as off-topic by Stephen Ostermiller Mar 7 at 19:12

  • This question does not appear to be about webmastering within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

    
There is certainly a way with CSS, but this question could get better answers at webmasters.stackexchange.com. – weeheavy Oct 25 '10 at 14:50
1  
I'd rather say this belongs to www.stackoverflow.com – Jurik Mar 7 at 16:38
    
Questions about how to program something in HTML are more appropriate for stackoverflow.com – Stephen Ostermiller Mar 7 at 19:12

To center a div both vertically and horizontally can be done a number of ways. A non-confusing one was given on stackoverflow a few days ago by Marko here and here is a working example (also including in the stackoverflow answer).

As suggested in the answer, if you do not want the div to scroll with the page then you can set

position: fixed

share

You can center a DIV horizontally and vertically with the following HTML and CSS code:

CSS

 .div-centered {
  position: absolute;
  margin: auto;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100px;
  height: 100px;
  background-color: green;
}

HTML

<div class="div-centered"></div>

You can place more content or other divs properly inside "div-centered".

Note: There are always more ways of achieving the same result through CSS.

http://codepen.io/anon/pen/aNdVVp

share