How to fix the position of the div tag at center of the page. using javascript
Po开发者_Python百科ssible Duplicate: how-to-align-a-div-to-the-middle-of-the-page
I need to show this Div tag allways center of the page. but its not showing now its shwoing right hand side corner and center of the page some times. Allways I need to show this page at center.
Thanks
You need to set a width to your div and add the margin css property shown below
<div style="width:500px; margin:0 auto;">
Your content
</div>
If you set width to 50%, then left position to 25% -> that way, your div will always be centered, no matter if you resize parent object.
#header {
width: 50%;
left: 25%;
}
<div id='test' class='#header'>My content goes here</div>
精彩评论