html - Vertically and Horizontally Aligning in CSS -
i'm having trouble getting form align both vertically , horizontally.
i don't mind if doesn't support ie--i plan on implementing ie detection script tell user use different browser--but support firefox , chrome must.
here have:
html
<!doctype html> <head> <link rel="stylesheet" type="text/css" href="global.css"> <link rel="stylesheet" type="text/css" href="index.css"> </head> <body> <div id="wrapper"> <div id="logo_div"> <img src="../images/logo.png" id="logo"> </div> <div id="login"> <form name="searchform" action="checklogin.php" method="post" id="login_form"> <br> user name : <input type="text" name="myusername" size="16" /><br> password : <input type="password" name="mypassword" /><br> <input type="submit" value="login" /><br> </form> </div> </div> </div> </body> </html>
global css
#wrapper { position: relative; max-width: 1024px; height: 1000px; margin-left: auto; margin-right: auto; } #logo_div { position: relative; margin-left: auto; margin-right: auto; } #logo { display: block; position: relative; margin-left: auto; margin-right: auto; }
index css
#login { position: relative; margin-left: auto; margin-right: auto; } #login_form { position: relative; margin-left: auto; margin-right: auto; }
any appreciated. thanks
do want this?
try css
#login{ position:absolute; left:50%; top:50%; margin-left:-120px; margin-top:-60px; border:1px solid #ccc; width:240px; height:120px; }
if want form centered vertically , horizontally, can use css attribute position:absolute; , use left:50%; top:50% align top-left corner of div center of browser. div not centered this. because centered window top left corner. used negative margin half of width , height of div center properly.
hope looking for.
thanks bojangles, suggestion !
Comments
Post a Comment