登陆界面设计

撸代码之前先来看一看效果图:

登陆界面由一个简单的表单(头像、用户名、密码、登陆按钮、记住我、取消、忘记密码),创建了一个CSS3的缩放效果构成。需要做浏览器(Firefox、Safari and Chrome、Opera)兼容处理和 @media 简单响应式设计。文本输入框做了 required 必须填写条件,运用在项目中可以通过 JavaScript 约束验证 DOM 方法checkValidity()、setCustomValidity()等做异常处理。

代码实现

HTML 页面布局:需引入下文的 JavaScript 脚本和 CSS 修饰

<body>
<!--此元素被显示-->
<button onclick="document.getElementById('id01').style.display='block'" style="width:auto;">登录</button>
<div id="id01" class="modal"><form class="modal-content animate" action=""><div class="imgcontainer"><!--此元素不会被显示--><span onclick="document.getElementById('id01').style.display='none'" class="close" title="Close Modal">&times;</span><img src="" alt="Avatar" class="avatar"></div><div class="container"><label><b>Username</b></label><input type="text" placeholder="Enter Username" name="uname" required>    <label><b>Password</b></label><input type="password" placeholder="Enter Password" name="psw" required><button type="submit">登陆</button><input type="checkbox" checked="checked"> 记住我</div><div class="container" style="background-color:#f1f1f1"><button type="button" onClick="document.getElementById('id01').style.display='none'" class="cancelbtn">Cancel</button><span class="psw">Forgot<a href="#">Password?</a></span></div></form>
</div>
</body>

JavaScript 脚本:通过 onclick 事件控制登陆模型的显示和关闭。event.target 可以理解为点击事件的聚焦点。

<script type = "text/javascript">
// 获取模型
var modal = document.getElementById('id01');
// 鼠标点击模型外区域关闭登录框
window.onclick = function(event) {if (event.target == modal) {// 此元素不会被显示modal.style.display = "none";}
}
</script>

CSS 修饰:

  • 文本输入框通过 input[type=text], input[type=password] 统一控制
  • cursor: pointer 光标呈现为指示链接的指针(一只手),cursor 控制贯标样式
  • border-radius: 50%  以百分比定义圆角的形状
  • position: fixed;  z-index: 1;  left: 0;  top: 0;   position、z-index、left、top共同控制模型在所有内容的上方(堆叠顺序1上方,-1下方)
  • @keyframes animatezoom  创建动画 animatezoom
  • @-webkit-keyframes animatezoom  设置动画兼容-webkit-引擎浏览器 Firefox
  • @-moz-keyframes animatezoom  设置动画兼容-moz-引擎浏览器 Safari and Chrome
  • @-o-keyframes animatezoom  设置动画兼容-o-引擎浏览器 Opera
  • -webkit-animation: animatezoom 0.6s  把动画添加到修饰器中并兼容设置
@charset "utf-8";
/* CSS Document *//* 宽屏输入字段 */
input[type=text], input[type=password] {width: 100%;padding: 12px 20px;margin: 8px 0;display: inline-block;border: 1px solid #ccc;box-sizing: border-box;
}/* 为所有按钮设置样式 */
button {background-color: #4CAF50;color: white;padding: 14px 20px;margin: 8px 0;border: none;cursor: pointer; /*光标呈现为指示链接的指针(一只手)*/width: 100%;
}button:hover {opacity: 0.8; /*设置 div 元素的不透明级别*/
}/* 取消按钮的其他样式 */
.cancelbtn {width: auto;padding: 10px 18px;background-color: #f44336;
}/* 将图像居中 */
.imgcontainer {text-align: center;margin: 24px 0 12px 0;position: relative;
}/*控制图片形状*/
img.avatar {width: 40%;border-radius: 50%; /*以百分比定义圆角的形状*/
}/* 定位关闭按钮 */
.close {position: absolute; /*生成绝对定位的元素,相对于 static 定位以外的第一个父元素进行定位。*/right: 25px;top: 0;color: #000;font-size: 35px;font-weight: bold;
}/* 光标移动到关闭按钮 */
.close:hover,
.close:focus {color: red;/*光标呈现为指示链接的指针(一只手)*/cursor: pointer;
}.container {padding: 16px;
}/* 忘记密码 */
span.psw {float: right;padding-top: 16px;
}/* 登陆弹框模型 */
.modal {display: none; /* 默认隐藏模型 */position: fixed; /* 生成绝对定位的元素,相对于浏览器窗口进行定位。 *//* z-index、left、top共同控制模型在所有内容的上方 */z-index: 1; left: 0;top: 0;width: 100%; /* Full width */height: 100%; /* Full height */overflow: auto; /* 如果需要,启用滚动条 */background-color: rgb(0,0,0); /* 回退颜色 */background-color: rgba(0,0,0,0.4); /* 黑色 */padding-top: 60px;
}/* 模型内容 */
.modal-content {background-color: #fefefe;margin: 5% auto 15% auto; /* 5% from the top, 15% from the bottom and centered */border: 1px solid #888;width: 30%; /* Could be more or less, depending on screen size */
}/* 添加缩放动画 */
.animate {-webkit-animation: animatezoom 0.6s; /*兼容-webkit-引擎浏览器*/-moz-animation: animatezoom 0.6s; /*兼容-moz-引擎浏览器*/-o-animation: animatezoom 0.6s; /*兼容-o-引擎浏览器*/animation: animatezoom 0.6s
}/*
1. transform:scale(x,y)
x表示元素沿着水平方向(X轴)缩放的倍数,y表示元素沿着垂直方向(Y轴)缩放的倍数。
注意,Y是一个可选参数,如果没有设置Y值,则表示X、Y两个方向的缩放倍数是一样的(同时放大相同倍数)。2. 关键词 "from" 和 "to",等同于 0% 和 100%。
0% 是动画的开始,100% 是动画的完成。
*//*创建动画animatezoom,把它绑定到 animate 选择器*/
@keyframes animatezoom {from {transform: scale(0)} to {transform: scale(1)}
}/* 设置动画兼容-webkit-引擎浏览器 Firefox */
@-webkit-keyframes animatezoom {from {transform: scale(0)} to {transform: scale(1)}
}/*设置动画兼容-moz-引擎浏览器 Safari and Chrome*/
@-moz-keyframes animatezoom {from {transform: scale(0)} to {transform: scale(1)}
}/*设置动画兼容-o-引擎浏览器 Opera*/
@-o-keyframes animatezoom {from {transform: scale(0)} to {transform: scale(1)}
}/*
@media 可以针对不同的屏幕尺寸设置不同的样式,特别是如果你需要设置设计响应式的页面,@media 是非常有用的。
这里,如果文档宽度小于 300 像素则操作修改,在额外的小屏幕上更改span和cancel按钮的样式 */
@media screen and (max-width: 300px) {span.psw {display: block;float: none;}.cancelbtn {width: 100%;}
}
  • @media screen and (max-width: 300px) :@media 可以针对不同的屏幕尺寸设置不同的样式,特别是如果你需要设置设计响应式的页面,@media 是非常有用的。如果文档宽度小于 300 像素则操作修改,在额外的小屏幕上更改span和cancel按钮的样式。

注意:

1. transform:scale(x,y)

x表示元素沿着水平方向(X轴)缩放的倍数,y表示元素沿着垂直方向(Y轴)缩放的倍数。

Y是一个可选参数,如果没有设置Y值,则表示X、Y两个方向的缩放倍数是一样的(同时放大相同倍数)。

2. 关键词 "from" 和 "to",等同于 0% 和 100%。0% 是动画的开始,100% 是动画的完成。

注册界面设计

撸码之前先来看一下效果图:

注册界面由一个简单的表单(Email、用户名、密码、重复密码、注册按钮、记住我、取消),创建了一个CSS3的缩放效果构成。同样需要做浏览器(Firefox、Safari and Chrome、Opera)兼容处理和 @media 简单响应式设计。文本输入框做了 required 必须填写条件,运用在项目中可以通过 JavaScript 约束验证 DOM 方法checkValidity()、setCustomValidity()等做异常处理。

代码实现

HTML 页面布局:同样需引入下文的 JavaScript 脚本和 CSS 修饰

<body>
<button onclick="document.getElementById('id01').style.display='block'" style="width:auto;">注册</button>
<div id="id01" class="modal"><span onclick="document.getElementById('id01').style.display='none'" class="close" title="Close Modal">&times;</span><form class="modal-content animate" action=""><div class="container"><label><b>Email</b></label><input type="text" placeholder="Enter Email" name="email" required><label><b>Password</b></label><input type="password" placeholder="Enter Password" name="psw" required><label><b>Repeat Password</b></label><input type="password" placeholder="Repeat Password" name="psw-repeat" required><input type="checkbox" checked="checked"> Remember me<p>By creating an account you agree to our <a href="#">Terms & Privacy</a>.</p><div class="clearfix"><button type="button" onclick="document.getElementById('id01').style.display='none'" class="cancelbtn">Cancel</button><button type="submit" class="signupbtn">Sign Up</button></div></div></form>
</div>
</body>

JavaScript 脚本:通过 onclick 事件控制登陆模型的显示和关闭。event.target 可以理解为点击事件的聚焦点。

<script type="text/javascript">// 获取模型var modal = document.getElementById('id01');// 鼠标点击模型外区域关闭登录框window.onclick = function(event) {if (event.target == modal) {modal.style.display = "none";}}
</script>

CSS 修饰:同登陆类似,文本输入框的统一控制、浏览器兼容处理、简单响应式的设计

@charset "utf-8";
/* CSS Document *//* 宽屏输入字段 */
input[type=text], input[type=password] {width: 100%;padding: 12px 20px;margin: 8px 0;display: inline-block;border: 1px solid #ccc;box-sizing: border-box;
}/* 为所有按钮设置样式  */
button {background-color: #4CAF50;color: white;padding: 14px 20px;margin: 8px 0;border: none;cursor: pointer;width: 100%;
}/* 取消按钮的其他样式 */
.cancelbtn {padding: 14px 20px;background-color: #f44336;
}/* 浮动取消和注册按钮,并添加一个相同的宽度 */
.cancelbtn,.signupbtn {float:left;width:50%}/* 向容器元素添加填充 */
.container {padding: 16px;
}/* 注册弹框模型 */
.modal {display: none; /* 在默认情况下隐藏 */position: fixed; /* 生成绝对定位的元素,相对于浏览器窗口进行定位。 *//* z-index、left、top共同控制模型在所有内容的上方 */z-index: 1; left: 0;top: 0;width: 100%; /* Full width */height: 100%; /* Full height */overflow: auto; /* 如果需要,启用滚动条 */background-color: rgb(0,0,0); /* 回退颜色 */background-color: rgba(0,0,0,0.4); /* 黑色 */padding-top: 60px;
}/* 模型内容 */
.modal-content {background-color: #fefefe;margin: 5% auto 15% auto; /* 5% from the top, 15% from the bottom and centered */border: 1px solid #888;width: 50%; /* Could be more or less, depending on screen size */
}/* 定位关闭按钮 */
.close {position: absolute;right: 35px;top: 15px;color: #000;font-size: 40px;font-weight: bold;
}/* 光标移动到关闭按钮 */
.close:hover,
.close:focus {color: red;/*光标呈现为指示链接的指针(一只手)*/cursor: pointer;
}/* 设置浮动*/
.clearfix::after {content: "";clear: both;display: table; /*此元素会作为块级表格来显示(类似 <table>),表格前后带有换行符。*/
}/* 添加缩放动画 */
.animate {-webkit-animation: animatezoom 0.6s; /*兼容-webkit-引擎浏览器*/-moz-animation: animatezoom 0.6s; /*兼容-moz-引擎浏览器*/-o-animation: animatezoom 0.6s; /*兼容-o-引擎浏览器*/animation: animatezoom 0.6s
}/*
1. transform:scale(x,y)
x表示元素沿着水平方向(X轴)缩放的倍数,y表示元素沿着垂直方向(Y轴)缩放的倍数。
注意,Y是一个可选参数,如果没有设置Y值,则表示X、Y两个方向的缩放倍数是一样的(同时放大相同倍数)。2. 关键词 "from" 和 "to",等同于 0% 和 100%。
0% 是动画的开始,100% 是动画的完成。
*//*创建动画animatezoom,把它绑定到 animate 选择器*/
@keyframes animatezoom {from {transform: scale(0)} to {transform: scale(1)}
}/* 设置动画兼容-webkit-引擎浏览器 Firefox */
@-webkit-keyframes animatezoom {from {transform: scale(0)} to {transform: scale(1)}
}/*设置动画兼容-moz-引擎浏览器 Safari and Chrome*/
@-moz-keyframes animatezoom {from {transform: scale(0)} to {transform: scale(1)}
}/*设置动画兼容-o-引擎浏览器 Opera*/
@-o-keyframes animatezoom {from {transform: scale(0)} to {transform: scale(1)}
}/*
@media 可以针对不同的屏幕尺寸设置不同的样式,特别是如果你需要设置设计响应式的页面,@media 是非常有用的。
这里,如果文档宽度小于 300 像素则操作修改,在额外的小屏幕上更改取消和注册按钮的样式 */
@media screen and (max-width: 300px) {.cancelbtn, .signupbtn {width: 100%;}
}
  • @media screen and (max-width: 300px):如果文档宽度小于 300 像素则操作修改,在额外的小屏幕上更改取消和注册按钮的样式 。

这里通过 JavaScript + CSS/CSS3 + HTML 简单的解释网页登陆 + 注册的界面设计,只是用于新手学习入门,还有很多的功能添加、异常处理等问题需要解决。在运用到项目中时可以根据业务进行拓展完善。

JavaScript + CSS/CSS3 + HTML 网页登陆 + 注册界面设计相关推荐

  1. html css实现登录注册页面,基于HTML5+css+JS_的精美登陆注册界面

    [实例简介] 基于HTML5+css+JS的精美登陆注册界面------------------------------- [实例截图] [核心代码] login4 ├── index.html ├─ ...

  2. php网页的注册界面设计,HTML开发博客之注册页面设计(一)

    CSS文件的引入 新建文件reg.html文件 首先我们来分析网页布局 这是我们页面完成后的效果, 网页分为三部分 头部,主体,和底部我们按照这个顺序开始编写. 头部导航栏的编写html> 用户 ...

  3. html5漂亮的登录与注册界面设计,漂亮的网页登陆/注册表单设计

    漂亮的网页登陆/注册表单设计 7月 4, 2012 评论 Sponsor 网页设计中登陆和注册表单是非常常用的,而且使用率也非常高,一个表单的设计其实也不是简单的事情,你要考虑很多用户体验,有的喜欢把 ...

  4. JavaScript+Css+Html实现网页换皮肤功能

    描述:JavaScript+Css+Html实现网页换皮肤功能 原理:使用不同网页背景保存在不同CSS里面,当点击切换的时候通过JavaScript将原来的样式表改为新的CSS就可以完成换肤功能 代码 ...

  5. H5与CSS所做的QQ注册界面

    Web中H5与CSS所做的QQ注册界面(不喜勿喷!) 下图一,完成样式 H5代码块 <!DOCTYPE html> <html lang="en"> < ...

  6. Flutter学习笔记(二)登陆注册界面的实现

    Flutter学习笔记(二)登陆注册界面的实现 简单的登录和注册界面的布局 SharedPreferences存储数据 页面路由和参数传递的心得 这几天按照顺序先完成了登录和注册的页面,没有什么特别的 ...

  7. 使用Java编写一个简单的 JFrame登陆注册界面(一)

    使用Java awt 及 Swing 组件编写一个简单的JFrame登陆注册界面. 示例: 下面开始介绍如何编写. 通过调用实例化一个JFrame框架,在框架内嵌入JPanel,在JPanel上进行添 ...

  8. Android 英语单词本英语单词记单词有登陆注册界面Android studio编译

    Android 英语单词本英语单词记单词有登陆注册界面Android studio编译 样例图: 项目视频: Android 单词本英语单词记单词有登陆注册界面,Android studio编译 项目 ...

  9. 右侧按钮登录注册html,翻转式用户登录注册界面设计

    这是一款非常实用的翻转式用户登录注册界面设计效果.该用户登录注册界面使用纯CSS3来制作,在用户点击登录和注册两个按钮时,登录和注册界面可以以水平翻转的方式来回切换,效果非常的酷. 制作方法 HTML ...

最新文章

  1. 3.列表(一个打了激素的数组)
  2. 双代号网络图基础算法_9个简单数学算法在管理领域的运用
  3. LeetCode 2037. 使每位学生都有座位的最少移动次数
  4. 解决mendeley不能输入中文的情况
  5. vs2008 成功编译 easyMule VeryCd V1.1.13
  6. Win10新电脑里的设备和驱动器下如何分盘
  7. matplotlib绘制树形图之基本配置——万能模板案例
  8. 《周一清晨的领导课》读书笔记
  9. 用sympy库解常微分方程
  10. html网页抓取建一个网站前端,创建网页的方法以及生成HTML骨架
  11. 【Redis】概述以及启动Redis并进入Redis
  12. MySQL数据库实验(四):E-R图实例讲解
  13. KBQA知识总结(学习笔记)
  14. Bypass部分知识
  15. PPO算法OpenAI论文大致翻译
  16. Linux - vi命令编辑后 wq 与 x 区别是什么?
  17. 视频服务器与流媒体服务器的区别和应用介绍
  18. 为什么说学习编程有助于提升专注力?
  19. 齐鲁医药学院计算机二级,[计算机]齐鲁医药学院计算机教研室莅临指导交流会顺利举行...
  20. 在ServletContextListener实现类中获取spring注入对象

热门文章

  1. xp计算机u盘重装系统,机械师电脑u盘重装系统xp教程
  2. 判断某整数是否既是5又是7的整数倍
  3. 防火墙添加ip白名单_如何给防火墙加白名单 防火墙添加ip白名单
  4. 禁用win10自带的微软输入法!
  5. 用 DiskGenius 解决移动硬盘变 RAW 问题
  6. 计算机思维与应用论文,计算机的思维与计算机应用关系分析
  7. 【渝粤教育】广东开放大学 证券投资学 形成性考核 (1)
  8. [Huffman树] aw149. 荷马史诗(哈夫曼模型+贪心)
  9. 怎样进网站空间服务器,怎样进网站空间服务器
  10. Mac系统 - zsh所有命令失效解决方式