Hi, How can I define a define float as center in css? actually i need a layout between right and left and also i tried "text-align" but it doesn't work and the "float" property just working.
Thank you
Hi, How can I define a define float as center in css? actually i need a layout between right and left and also i tried "text-align" but it doesn't work and the "float" property just working.
Thank you
You can only float an element to the left or the right.
Maybe describe what kind of layout you are trying to achieve.
There is no float: center. but when you want a div to be centered to its parent this should do the trick:
#parent-element{
position: relative;
}
#element
{
width: 500px;
left: 50%;
margin-left: -250px; /* - (width/2) */
position: absolute;
}
but, what exactly are you trying to achieve?
You want something like this:
<div style="width: 500px; text-align: center;">
<div style="margin: 0 auto; width: 100px;">I am centered</div>
</div>
The key is text-align: center on the parent, and a margin: 0 auto on the inner element