Solved

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

Posted on 2011-02-15
2
328 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Creating a CSS block that only applies to printing By default, all of your CSS applies to every possible view of your page - whether on screen, printed, landscape, touch-screen, or whatever.  You can, however, add CSS that only applies under certai…
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 to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

756 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