<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <style type="text/css"> *{font-size:12px;} #head{ font-size:12px; padding:6px 0 0 10px;} #loginbox{width:300x; height:150px; background:#eee; border:1px solid #ccc; position:absolute;left:50%;top:50%;; margin-left:-150px; margin-top:-75px;display:none;} #loginbox p{ height:20px; border-bottom:1px sold red; font-size:12px; font-weight:bold; padding:6px 0 0 5px;} #close{ cursor:pointer; width:14px; height:14px; position:absolute; right:4px; top:6px;} </style> <script type="text/javascript"> window.onload=function(){ var login=document.getElementById("login"), close1=document.getElementById("close"), loginbox=document.getElementById("loginbox"); //添加事件 function addEvent(ele,type,hander){ if(ele.addEventListener){ ele.addEventListener(type,hander,false); }else if(ele.attachEvent){ ele.attachEvent("on"+type,hander); }else{ ele["on"+type]=hander; } } function showloginbox(){ loginbox.style.display="block"; } function hideloginbox(){ loginbox.style.display="none"; } addEvent(login,"click",showloginbox); addEvent(close1,"click",hideloginbox); } </script> </head> <body> <div id="head"> 亲,您好! <input id="login" type="button" value="登录"/> </div> <div id="loginbox"> <p>用户登录</p> <span id="close">a</span> </div> </body>
登录弹出框的样式怎么是,下图,是哪错了?
#loginbox{width:300px; height:150px; background:#eee; border:1px solid #ccc; position:absolute;left:50%;top:50%;; margin-left:-150px; margin-top:-75px;display:none;}
width:300px丢了p,写成了300x,所以宽度没有起作用
后面还写错一个solid