Solved

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

Posted on 2011-02-15
2
311 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
Comment Utility
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
Comment Utility
Great, this seems to have actually worked out very well in this case. Thank you!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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.
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now