Reputation: 79666
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)
Upvotes: 0
Views: 3599
Reputation: 19263
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)
Upvotes: 2
Reputation: 5508
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%;">
Upvotes: 0
Reputation: 29267
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;
}
Upvotes: 5
Reputation: 38603
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.
Upvotes: 4