一、实现结果
二、实现过程
实现这个界面,分四个部分:css+js+jsp+两张图片
注意:他们存放的地址,如果实现结果不是上图,注意看图片地址是否写对,css,jsp,js地址和名字是否写对
1.css部分——创建mylogincss文件
body{
margin:0;
padding:0;
background:url("../img/bg_all.jpg") no-repeat;
background-size:100%;
}
html{
height: 100%;
box-shadow:0px 0px 300px #000 inset;
-webkit-box-shadow:0px 0px 50px #000 inset;
}
form{
position:absolute;
left:50%;
top:50%;
margin-left:-300px;
margin-top:-220px;
width:480px;
height:380px;
background:url("../img/b.png") no-repeat;
border-radius:25px;
color:#fff;
text-align:center;
padding:65px;
/*box-shadow: 0px 0px 15px #0005;*/
}
.input_1{
outline:none;
margin-top:10px;
border:0;
width:300px;
height:50px;
border-radius:15px;
padding-left:15px;
font-size:18px;
color:#999;
}
.input_2{
margin:20px 0px;
border:0;
background:#fff;
}
h1{
color:#fff;
}
/*单选*/
.radio_box{ display:inline-block; position:relative;margin:20px 5px;}
.radio_box label{ width:15px; height:15px; position:absolute; top:0; left:0; border:2px solid #3A5367; border-radius:50%; background:#fff; cursor:pointer;}
.radio_box input:checked + label:after{ content:''; width:9px; height:9px; position:absolute; top:3px; left:3px; background:#3A5367; border-radius:50%;}
.check_box em{ margin:0 0 0 5px;}
.input_3{
outline: none;
width:50px;
height:30px;
border:0;
padding:5px 7px;
background:#fff;
border-radius:20px;
margin:0px 10px;
}
2.js部分——创建myloginjs文件
function login(){
if(form1.username.value==''){
alert('用户名不能为空!');
return false;
}
if(form1.password.value==''){
alert('密码不能为空!');
return false;
}
form1.action="#";
form1.submit();
}
window.onload = function(){
var i3 = document.getElementsByClassName('input_3');
for(var i=0;i<i3.length;i++){
i3[i].onmouseover = function(){
this.style.backgroundColor = "#23271F";
this.style.color = "#fff";
}
i3[i].onmouseout = function(){
this.style.backgroundColor = "#fff";
this.style.color = "#23271F";
}
}
var pass = document.getElementById("password");
pass.onfocus = function(){
pass.type = "password";
}
}
3.jsp部分——创建mylogin文件
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>登录界面</title>
<meta charset="utf-8">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" type="text/css" href="qiantai/mylogincss.css">
</head>
<body>
<form name="form1" action="" method="post">
<h1>WWW餐厅欢迎您</h1>
<input class=input_1 id=username size=15 name="username" placeholder=用户名><br />
<input class=input_1 id=password type=text size=15 name="password" placeholder=密码><br />
<span class="radio_box">
<input type="radio" id="radio_1" name="gettype" value="users" checked>
<label for="radio_1"></label>
普通用户
</span>
<span class="radio_box">
<input type="radio" id="radio_2" name="gettype" value="admin">
<label for="radio_2"></label>
管理员
</span><br/>
<input class=input_3 type="button" onclick="login()" value="登录" />
<input class=input_3 type="button" onclick=document.form1.reset() value="重置" />
</form>
<script type="text/javascript" src="qiantai/myloginjs.js"></script>
</body>
</html>
4.图片
图片b:
图片bg_all