扁平风格登录注册表单界面

所属分类:输入-验证,丰富的输入

 41318  389  查看评论 (6)
分享到微信朋友圈
X
扁平风格登录注册表单界面 ie兼容10

该扁平风格登录注册表单界面的HTML结构如下:

<div id="wrapper" >
 <div id="login_form" >
   <form >
     <input type="text" placeholder="用户名" id="r_user_name"/>
     <input type="password" placeholder="密码" id="r_password" />
     <input type="text" placeholder="电子邮件" id="r_emial"/>
     <button id="create">创建账户</button>
     <p >已经有了一个账户? <a href="#">立刻登录</a>
   </form>
   <form >
     <input type="text" placeholder="用户名" id="user_name"/>
     <input type="password" placeholder="密码" id="password"/>
     <button id="login">登 录</button>
     <p >还没有账户? <a href="#">立刻创建</a>
   </form>
 </div>
</div>

为表单添加下面的必要CSS样式:

@import url(https://fonts.googleapis.com/css?family=Roboto:300);
.login-page {
 width: 360px;
 padding: 8% 0 0;
 margin: auto;
}
.form {
 position: relative;
 z-index: 1;
 background: #FFFFFF;
 max-width: 360px;
 margin: 0 auto 100px;
 padding: 45px;
 text-align: center;
 box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24);
}
.form input {
 font-family: "Roboto", sans-serif;
 outline: 0;
 background: #f2f2f2;
 width: 100%;
 border: 0;
 margin: 0 0 15px;
 padding: 15px;
 box-sizing: border-box;
 font-size: 14px;
}
.form button {
 font-family: "Microsoft YaHei","Roboto", sans-serif;
 text-transform: uppercase;
 outline: 0;
 background: #4CAF50;
 width: 100%;
 border: 0;
 padding: 15px;
 color: #FFFFFF;
 font-size: 14px;
 -webkit-transition: all 0.3 ease;
 transition: all 0.3 ease;
 cursor: pointer;
}
.form button:hover,.form button:active,.form button:focus {
 background: #43A047;
}
.form .message {
 margin: 15px 0 0;
 color: #b3b3b3;
 font-size: 12px;
}
.form .message a {
 color: #4CAF50;
 text-decoration: none;
}
.form .register-form {
 display: none;
}
.container {
 position: relative;
 z-index: 1;
 max-width: 300px;
 margin: 0 auto;
}
.container:before, .container:after {
 content: "";
 display: block;
 clear: both;
}
.container .info {
 margin: 50px auto;
 text-align: center;
}
.container .info h1 {
 margin: 0 0 15px;
 padding: 0;
 font-size: 36px;
 font-weight: 300;
 color: #1a1a1a;
}
.container .info span {
 color: #4d4d4d;
 font-size: 12px;
}
.container .info span a {
 color: #000000;
 text-decoration: none;
}
.container .info span .fa {
 color: #EF3B3A;
}
body {
 background: #76b852; /* fallback for old browsers */
 background: -webkit-linear-gradient(right, #76b852, #8DC26F);
 background: -moz-linear-gradient(right, #76b852, #8DC26F);
 background: -o-linear-gradient(right, #76b852, #8DC26F);
 background: linear-gradient(to left, #76b852, #8DC26F);
 font-family: "Roboto", sans-serif;
 -webkit-font-smoothing: antialiased;
 -moz-osx-font-smoothing: grayscale;      
}

表单左右摇晃的效果使用CSS3 animation动画来实现:

.shake_effect{
 -webkit-animation-name: shake;
   animation-name: shake;
   -webkit-animation-duration: 1s;
   animation-duration: 1s;
}
@-webkit-keyframes shake {
 from, to {
   -webkit-transform: translate3d(0, 0, 0);
   transform: translate3d(0, 0, 0);
 }
 10%, 30%, 50%, 70%, 90% {
   -webkit-transform: translate3d(-10px, 0, 0);
   transform: translate3d(-10px, 0, 0);
 }
 20%, 40%, 60%, 80% {
   -webkit-transform: translate3d(10px, 0, 0);
   transform: translate3d(10px, 0, 0);
 }
}
@keyframes shake {
 from, to {
   -webkit-transform: translate3d(0, 0, 0);
   transform: translate3d(0, 0, 0);
 }
 10%, 30%, 50%, 70%, 90% {
   -webkit-transform: translate3d(-10px, 0, 0);
   transform: translate3d(-10px, 0, 0);
 }
 20%, 40%, 60%, 80% {
   -webkit-transform: translate3d(10px, 0, 0);
   transform: translate3d(10px, 0, 0);
 }
}

简单的对表单进行了一些验证 方法

function check_login(){
var name=$("#user_name").val();
var pass=$("#password").val();
if(name=="admin" && pass=="admin"){
 alert("登录成功!");
 $("#user_name").val("");
 $("#password").val("");
}
else{
 $("#login_form").removeClass('shake_effect');  
 setTimeout(function()
 {
  $("#login_form").addClass('shake_effect')
 },1);  
}
}
function check_register(){
 var name = $("#r_user_name").val();
 var pass = $("#r_password").val();
 var email = $("r_email").val();
 if(name!="" && pass=="" && email != "")
  {
   alert("注册成功!");
   $("#user_name").val("");
   $("#password").val("");
  }
  else
  {
   $("#login_form").removeClass('shake_effect');  
   setTimeout(function()
   {
    $("#login_form").addClass('shake_effect')
   },1);  
  }
}
相关插件-验证,丰富的输入

简单易懂的jQuery表单验证插件

这是一款简单易懂的表单验证插件,没用使用任何多余的代码,使用时仅需引用jquery和jquery.validate.js
  验证
 32724  336

jQuery滑动拼图验证插件SliderImgPuzzle(原创)

仿造网络上的类似的拼图控件,还有结合自己的项目封装的
  验证
 44735  368

jquery多功能表单验证

基于jquery封装的表单验证插件
  验证
 40736  362

漂亮的登录注册页+Validate表单验证+自适应手机

在“漂亮的登录页+滑动弹出框+js正则验证”的基础上,添加自适应样式和优化输入时体验,增加Validate的表单验证
  验证
 81404  770

讨论这个项目(6)回答他人问题或分享插件使用方法奖励jQ币 评论用户自律公约

    昵称不再换啦 0
    2019/7/10 13:40:06
    很棒 很不错 支持作者 回复
    ?(??? ? ???)? 0
    2019/7/6 13:57:42
    为什么登录成功后没法跳转网页,只是清空了输入框?
        西瓜0
        2019/7/6 14:05:00

        这是个基础性问题,这里只给个演示,登录成功跳转代码自己加一下就行了。
        195行代码改

        window.location.href = "你要跳转的url";
    回复
    水永舟亢 0
    2019/6/2 10:22:37
    这个.container .info 它是....干嘛用的?示例代码中没看到啊 回复
    好久不见 0
    2019/1/8 3:50:31
    请问 我多增加了 一个找回密码的界面 结果 我新增的这个界面和创建账号的界面一起出现 而且我不明白<a href="#"></a>是怎么在两个界面之间切换的,我想做到我所增加的找回密码界面和原来的登录界面、创建界面三者切换
        石榴「小生」0
        2019/2/12 11:25:58
        创建两个一样的.html文件,分别取名为retrievePwd.html和login.html;通过a标签将两个页面链接起来
    回复
😃
  • 😀
  • 😉
  • 😥
  • 😵
  • 😫
  • 😘
  • 😡
  • 👍
  • 🌹
  • 👏
  • 🍺
  • 🍉
  • 🌙
  • 💖
  • 💔
😃
  • 😀
  • 😉
  • 😥
  • 😵
  • 😫
  • 😘
  • 😡
  • 👍
  • 🌹
  • 👏
  • 🍺
  • 🍉
  • 🌙
  • 💖
  • 💔
取消回复