Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-02-15
2
Medium Priority
?
351 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
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…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
Suggested Courses

783 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