Solved

position:absolute, I would like to center in available space, defaults to left

Posted on 2011-02-15
2
321 Views
Last Modified: 2012-05-11
Experimenting with absolute positioning:

      div.slide-table-container {
                  z-index: 1;
                  position: absolute;
                  top: 288px;
            }

If I don't specify a left: 000px; value, then it seems to default to pushing my div against the left edge of its containing div. Is it possible to center an absolute positioned div in the available horizontal space? Thank you.
0
Comment
Question by:bbdesign
2 Comments
 
LVL 10

Accepted Solution

by:
cyberstalker earned 500 total points
ID: 34897734
It is. But if you want it to work in Internet Explorer too, you will have to explicitly specify a width for your element.

 
div.slide-table-container {
    z-index: 1;
    position: absolute;
    top: 288px;
    left: 50%;
    margin-left: -[half of the width]px;
    width: [your width here]px;
}

Open in new window


Note the minus sign in front of the margin-left.
0
 

Author Comment

by:bbdesign
ID: 34897848
Great, this seems to have actually worked out very well in this case. Thank you!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…

808 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