tags:

views:

74

answers:

4

i´ve got elements inside a containing div with a class.

i could use text-align: center on the div and that will center all elements.

how could i position the elements with exact pixels from the left?

(i dont want to use css on the element but on the containing div)

+3  A: 

The closest you could get with only the div is to play with the padding, but the correct solution would be to apply left/top to the inner elements.

Also, this belongs on doctype.com.

Max Shawabkeh
+4  A: 

You can use padding-left on the container div. However this will augment the width of the div itself, since you're adding left padding to it. To solve this problem you should use margin-left on the inner divs, for example:

/* apply a margin left to all the divs
 * inside div.container
 */
div.container div {
    margin-left:20px;
}
Luca Matteis
A: 

Hello this is what your looking for < div style="position:absolute;height:100px;width:100px;top:100px;left:100px;"> You can put that style on any tag you want Enjoy! and to be into the middle use I.E
< div style="position:absolute;top:0px;left:50%;">

H4cKL0rD
+1  A: 

Set position: relative
Set top: ..px
Set left: ..px

I think this solution is prettier than setting margins/paddings.

(I'm typing this on an iPhone can't format it for ya)

Zyphrax
The question was asking for how to do it without touching the inner elements, hence the padding hack.
Max Shawabkeh