Reputation: 1266
I'd simply like to center a DIV object to the browser screen.
It should be something like that I think..
<div id="root">
<div id="centeredElement"></div>
</div>
div#root {
width:100%;
}
div#centeredElement {
width:500px;
height:200px;
align:center;
}
Upvotes: 3
Views: 26914
Reputation: 56487
you have several options to center a div, image or other object:
1) everything inside div
<div align="center"> blabla </div>
2) for images or frames
<img style="display:block;margin-left:auto;margin-right:auto;" align="center" src="xx.jpg" />
3) another:
<div style="width:80%;margin-left:10%;"> blabla </div>
Upvotes: 2
Reputation: 32192
text-align:center
or margin:0 auto;
as like this
div#centeredElement{
text-align:center;
}
or
div#centeredElement{
margin:0 auto;
}
Upvotes: 3