Set the position of DIV
I'm showing the following &开发者_JAVA百科lt;div> conditionally in a JSP page:
<div id="error_message">Wrong nickname or password!</div>
The style of the DIV defined as follows:
div#error_message{
width: 200px;
left: 400px;
top: 400px;
}
However, it appears at left 0 and top 0 instead of left 400px and top 400px. What am I doing wrong? How do I make the <div> to appear in the middle?
You need to give it a position other than static (the default) for top and left to have an effect, for example:
div#error_message{
width: 200px;
left: 400px;
top: 400px;
position: absolute;
}
加载中,请稍侯......
精彩评论