I want to float a div
to center. Is it possible? text-align: center
is not working in IE.
You can do this by setting the display property to "flex." Then define the align-items and justify-content property to “center.” This will tell the browser to center the flex item (the div within the div) vertically and horizontally.
use text-align:center for div -> this will align text inside div center. include width property in div (i.e. width:200px) and it will work fine.
One way to center a Div in CSS is to set the position to absolute and set the left and right property values to 50% which will move the div to the center.
There is no float to center per se. If you want to center a block element inside another do this:
<div id="outer"> <div id="inner">Stuff to center</div> </div>
with:
#outer { width: 600px; } #inner { width: 250px; margin: 0 auto; }
Now that won't make the text wrap around it (like it would with a float left or right) but like I said: there is no float center.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With