登录页
一个通用的登录界面:

鼠标放上去效果(IE8好像不起作用):

所用图片:

页面HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>系统登录</title>
<link href="css/login.css" rel="stylesheet" type="text/css" />
</head>
<body style="text-align:center;" >
<div class="container">
<div class="login">
<div class="login_top"></div>
<div class="login_center">
<div class="form_body">
<input name="textfield" type="text" class="Username_input" id="textfield" placeholder="Username" />
<input name="textfield2" type="Password" class="Password_input" id="textfield2" placeholder="Password"/>
<div class="button_body">
<div class="error" id="error"></div>
<input name="loginBtn" id="loginBtn" type="submit" value="登 录" class="login_button" onclick="loginSubmit();">
</div>
</div>
</div>
</div>
</div>
</body>
</html>
防止按钮错位,加了个button_body的DIV
分步分析:
1、整个body样子即最终效果样子
但其去掉background后效果如图(两边是白的,页面上看不出):

说明.container只是中间那部分,两边是使用背景条填充的。即材料中的login_bg图片
* {
margin: 0;
padding: 0;
}
body {
font-family: "Lucida Grande", Verdana, Lucida, Arial, Helvetica, sans-serif;
font-size: 12px;
background: #2a445f url(../images/login/login_bg.jpg) left top repeat-x;
}
2、.container部分
即去掉两边填充的空白后的这块

.container {
position:absolute;
width: 850px;
height: 588px;
left: 50%;
top: 0;
margin-left: -425px;
background:url(../images/login/login_bg2.jpg) 0 0 no-repeat;
}
3、.login部分
中间蓝色阴影部分,真正的登录框部分

.login {
margin: 133px 0 0 234px;
width:382px;
height:282px;
}
4、login_top部分
真正登录框中,上面蓝色阴影部分。

.login_top {
width: 382px;
height: 115px;
float:left;
margin:0px;
background: url(../images/login/login_top.png) no-repeat;
}
5、login_center部分
真正登录框中,下面阴影部分

.login_center {
width: 382px;
height: 167px;
float:left;
margin:0px;
background:url(../images/login/login_center.png) no-repeat;
}
6、form_body部分
阴影部分

.form_body {
padding-left: 46px;
float: left;
width: 290px;
height: 143px;
}
form_body为margin-left时,IE下会错位,原因未知。。
文本框通用部分:
input[type="text"], input[type="password"] {
background-color: #ffffff;
border: 1px solid #d5d5d5;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
-webkit-transition: border linear 0.2s, box-shadow linear 0.2s;
-moz-transition: border linear 0.2s, box-shadow linear 0.2s;
-o-transition: border linear 0.2s, box-shadow linear 0.2s;
transition: border linear 0.2s, box-shadow linear 0.2s;
}
注意几点:
1、文本框后面的小人是通过background,偏移实现
input.Username_input {
background: url(../images/login/icon_input.png) 99% 9px no-repeat;
..
}
2、LOGO与文本框间的空白是通过在LOGO下留白实现
3、整个界面的底色是通过小背景图片填充实现
4、鼠标移动上去边框变粗,聚焦时边框变色(小细节)
input.Username_input {
background: url(../images/login/icon_input.png) 99% 9px no-repeat;
margin-bottom: 11px;
padding: 0;
padding-top: 6px;
height: 32px;
width: 288px;
color: #555;
font-size: 14px;
border: 1px solid #d5d5d5;
background-color: fff;
line-height: 14px;
text-indent: 6px;
}
input.Username_input:hover {
background: url(../images/login/icon_input.png) 99% 9px no-repeat;
border: 1px solid #b5b5b5;
}
input.Username_input:focus {
background: url(../images/login/icon_input.png) 99% -31px no-repeat;
border-color: rgba(82, 168, 236, 0.8);
/* IE6-9 */
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
}
全部CSS代码:
/* CSS Document */
* {
margin: 0;
padding: 0;
}
body {
font-family: "Lucida Grande", Verdana, Lucida, Arial, Helvetica, sans-serif;
font-size: 12px;
background: #2a445f url(../images/login/login_bg.jpg) left top repeat-x;
}
.container {
position:absolute;
width: 850px;
height: 588px;
left: 50%;
top: 0;
margin-left: -425px;
background:url(../images/login/login_bg2.jpg) 0 0 no-repeat;
}
.login {
margin: 133px 0 0 234px;
width:382px;
height:282px;
}
.login_top {
width: 382px;
height: 115px;
float:left;
margin:0px;
background: url(../images/login/login_top.png) no-repeat;
}
.login_center {
width: 382px;
height: 167px;
float:left;
margin:0px;
background:url(../images/login/login_center.png) no-repeat;
}
.form_body {
padding-left: 46px;
float: left;
width: 290px;
height: 143px;
}
input[type="text"], input[type="password"] {
background-color: #ffffff;
border: 1px solid #d5d5d5;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
-webkit-transition: border linear 0.2s, box-shadow linear 0.2s;
-moz-transition: border linear 0.2s, box-shadow linear 0.2s;
-o-transition: border linear 0.2s, box-shadow linear 0.2s;
transition: border linear 0.2s, box-shadow linear 0.2s;
}
input.Username_input {
float: left;
background: url(../images/login/icon_input.png) 99% 9px no-repeat;
margin-bottom: 11px;
padding: 0;
padding-top: 6px;
height: 32px;
width: 288px;
color: #555;
font-size: 14px;
border: 1px solid #d5d5d5;
background-color: fff;
line-height: 14px;
text-indent: 6px;
}
input.Username_input:hover {
background: url(../images/login/icon_input.png) 99% 9px no-repeat;
border: 1px solid #b5b5b5;
}
input.Username_input:focus {
background: url(../images/login/icon_input.png) 99% -31px no-repeat;
border-color: rgba(82, 168, 236, 0.8);
/* IE6-9 */
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
}
input.Password_input {
float: left;
background: url(../images/login/icon_input.png) 99% -71px no-repeat;
margin-bottom: 11px;
padding: 0;
padding-top: 6px;
height: 32px;
width: 288px;
color: #555;
font-size: 14px;
border: 1px solid #d5d5d5;
background-color: fff;
line-height: 14px;
text-indent: 6px;
}
input.Password_input:hover {
background: url(../images/login/icon_input.png) 99% -71px no-repeat;
border: 1px solid #b5b5b5;
}
input.Password_input:focus {
background: url(../images/login/icon_input.png) 99% -111px no-repeat;
border-color: rgba(82, 168, 236, 0.8);
/* IE6-9 */
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
}
.button_body {
float: left;
margin-top: 14px;
width: 290px;
height: 35px;
}
input.login_button {
float: right;
clear: right;
background: #215a98 url(../images/login/icon_key.png) 22px 9px no-repeat;
cursor: pointer;
border: 1px solid #1a497d;
border-bottom: 1px solid #283b4f;
width: 102px;
height: 35px;
font-family: "微软雅黑";
font-size: 15px;
color: #fff;
text-indent: 21px;
}
input.login_button:hover {
background: #1e4b84 url(../images/login/icon_key.png) 22px 9px no-repeat;
cursor: pointer;
border: 1px solid #173e69;
border-bottom: 1px solid #123860;
}
.error {
float: left;
margin-top: 8px;
font-size: 12px;
color: #F00;
}
..