Solved

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

Posted on 2011-02-15
2
332 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Title # Comments Views Activity
How to make button inactive until I fill in all the boxes. 11 36
Flex Messes  With Horizontal Positioning 2 35
Text color in a select 11 32
Web page design problem 3 41
CSS3 Custom checkboxes This article shows how to style the checkbox form element using only CSS. Works in: Chrome, FF, Safari, Opera, IE9+ Uses modernizr.js to check for :checked pseudo class, falling back to plain old checkboxes (IE8 and bel…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
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…

734 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