tags:

views:

39

answers:

2

Hi guys :|

My "div" element have a relative width, it isn't absolute so I can't use exact numbers to centralize. A nice solution is to use "display: inline-block":

body {
    text-align: center;
}

#myDiv {
    border: 1px solid black;
    display: inline-block;
    padding: 50px;
}

But this element NEEDS to float, I tried this:

#myDiv {
    border: 1px solid black;
    display: inline-block;
    float: left;
    padding: 50px;
}

And this:

#myDiv {
    border: 1px solid black;
    display: inline-block;
    padding: 50px;
    position: absolute;
}

Without any success, can somebody help me ?

Thanks

A: 
#myDiv {
    margin: 0 auto;
}
steve_c
A: 

You can center any block element with this css:

margin:auto;
width: some fixed value;

So elment need to have fixed width, in order to be centerd like this.

GaVrA