开发者

Set the position of DIV

开发者 https://www.devze.com 2023-02-01 07:29 出处:网络
I\'m showing the following &开发者_JAVA百科lt;div> conditionally in a JSP page: <div id=\"error_message\">Wrong nickname or password!</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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消