使用css3制作登录表单的步骤


Posted in HTML / CSS onApril 07, 2014

使用css3制作登录表单的步骤

制作步骤:

一, 引入prefixfree.js脚本

下面代码中使用了CSS3无前缀脚本prefixfree.js,可以省去CSS3中前缀“-moz”、“-webkit”、“-o”、“-ms”。

复制代码
代码如下:

<script type="text/javascript" charset="UTF-8" src="prefixfree.min.js"></script>

二, <body>标签结构

复制代码
代码如下:

<body>
<div class="content">
<form action="" method="post" class="login-form">
<div class="username">
<input type="text" name="username" placeholder="" autocomplete="on" />
<span class="user-icon icon">u</span>
</div>
<div class="password">
<input type="password" name="password" placeholder="" />
<span class="password-icon icon">p</span>
</div>
<div class="account-control">
<input type="checkbox" name="Remember me" id="Remember me" value="Remember me" checked="checked" />
<label for="Remember me" data-on="c" class="check"></label>
<label for="Remember me" class="info">Remember me</label>
<button type="submit">Login</button>
</div>
</form>
</div>
</body>

三,CSS代码

复制代码
代码如下:

body {
background: url(bg.png);
background-size: 100% 100%;
margin:0;
padding:0;}
.content {
width:600px;
height:420px;
margin:50px auto;
}
.login-form {
width:400px;
height:177px;
margin:70px auto 0;
padding-top:73px;
position:relative;
background-image:-*-linear-gradient(top,rgb(255,255,255),rgb(242,242,242));
box-shadow:0 3px 3px rgba(21,62,78,0.8);
}
.login-form:before {
content:"";
position:absolute;
top:-50px;
left:150px;
width:102px;
height:102px;
padding:2px;
border:1px solid rgb(216,216,219);
background:#fff url("profilepicture.jpg") no-repeat 2px 2px;
}
.not-registered {
position:absolute;
color:rgb(153,153,153);
font-weight:bold;
font-size:13px;
top:calc(100% + 20px);
background-color:rgb(255,255,255);
width:400px;
height:46px;
margin:0 auto;
line-height:46px;
text-align: center;
box-shadow:0 3px 3px rgba(21,62,78,0.8);
}
.not-registered a {
margin-left:5px;
text-decoration: none;
color:rgb(52,119,182);
cursor: pointer;
}
.login-form div {
width:216px;
height:28px;
margin:20px auto;
position:relative;
line-height:28px;
border:none;
}
.login-form .user-icon,
.login-form .password-icon {
display:inline-block;
font-family: 'loginform-icon';
font-size:15px;
text-align:center;
line-height:28px;
color:rgb(153,153,153);
position:absolute;
left:1px;
top:1px;
background-color:rgb(255,255,255);
border:none;
border-right:1px solid rgb(229,229,232);
width:30px;
height:28px;
transition: all 300ms linear;
}
.login-form .username input, .login-form .password input {
height:100%;
width:calc(100% - 40px);
padding-left:40px;
border-radius:2px;
border:1px solid;
border-color:rgb(229,229,232) rgb(220,220,221) rgb(213,213,213) rgb(220,220,221);
display:block;
transition: all 300ms linear;
}</p> <p>.login-form .icon:before, .login-form .icon:after {
content:"";
position:absolute;
top:10px;
left:30px;
width:0;
height:0;
border:4px solid transparent;
border-left-color:rgb(255,255,255);
}
.login-form .icon:before {
top:9px;
border:5px solid transparent;
border-left-color:rgb(229,229,232);
}
.login-form .username input:focus, .login-form .password input:focus {
border-color:rgb(69,153,228);
box-shadow:0 0 2px 1px rgb(200,223,244);
}
.login-form .username input:focus + span, .login-form .password input:focus + span {
background:-*-linear-gradient(top,rgb(255,255,255),rgb(245,245,245));
color:rgb(51,51,51);
}
.login-form .username input:focus + span:after, .login-form .password input:focus + span:after {
border-left-color:rgb(250,250,250);
}</p> <p>.login-form .account-control label {
margin-left:24px;
font-size:12px;
font-family: Arial, Helvetica, sans-serif;
cursor:pointer;
}
.login-form button[type="submit"] {
color:#fff;
font-weight:bold;
float:right;
width:68px;
height:30px;
position:relative;
background:-*-linear-gradient(top,rgb(74,162,241),rgb(52,119,182)) 1px 0 no-repeat,
-*-linear-gradient(top,rgb(52,118,181),rgb(36,90,141)) left top no-repeat;
background-size:66px 28px,68px 29px;
border:none;
border-top:1px solid rgb(52,118,181);
border-radius:2px;
box-shadow:inset 0 1px 0 rgb(86,174,251);
text-shadow:0 1px 1px rgb(51,113,173);
transition: all 200ms linear;
}
.login-form button[type="submit"]:hover {
text-shadow:0 0 2px rgb(255,255,255);
box-shadow:inset 0 1px 0 rgb(86,174,251),0 0 10px 3px rgba(74,162,241,0.5);
}
.login-form button[type="submit"]:active {
background:-*-linear-gradient(top,rgb(52,119,182),rgb(74,162,241)) 1px 0 no-repeat,
-*-linear-gradient(top,rgb(52,118,181),rgb(36,90,141)) left top no-repeat;
}</p> <p>.login-form .account-control input {
width:0px;
height:0px;
}
.login-form label.check {
position:absolute;
left:0;
top:50%;
margin:-8px 0;
display:inline-block;
width:16px;
height:16px;
line-height: 16px;
text-align:center;
border-radius:2px;
background:-*-linear-gradient(top,rgb(255,255,255),rgb(246,246,246)) 1px 1px no-repeat,
-*-linear-gradient(top,rgb(227,227,230),rgb(165,165,165)) left top no-repeat;
background-size:14px 14px,16px 16px;
}
.login-form .account-control input:checked + label.check:before {
content:attr(data-on);
font-family:loginform-icon;
}
@font-face {
font-family: 'loginform-icon';
src: url("font/loginform-icon.eot");
src: url("font/loginform-icon.eot?#iefix") format('embedded-opentype'),
url("font/loginform-icon.woff") format('woff'),
url("font/loginform-icon.ttf") format('truetype'),
url("font/loginform-icon.svg#loginform-icon") format('svg');
font-weight: normal;
font-style: normal;
}

OK,制作完成!自己动手试试吧。

HTML / CSS 相关文章推荐
CSS3之边框多颜色Border-color属性使用示例
Oct 11 HTML / CSS
CSS3中媒体查询结合rem布局适配手机屏幕
Jun 10 HTML / CSS
深入剖析webstorage[html5的本地数据处理]
Jul 11 HTML / CSS
IE支持HTML5的解决方法
Oct 20 HTML / CSS
html5定位获取当前位置并在百度地图上显示
Aug 22 HTML / CSS
详解HTML5中的manifest缓存使用
Sep 09 HTML / CSS
HTML5 新标签全部总汇(推荐)
Jun 13 HTML / CSS
html5默认气泡修改的代码详解
Mar 13 HTML / CSS
基于html5 canvas做批改作业的小插件
May 20 HTML / CSS
HTML5实现直播间评论滚动效果的代码
May 27 HTML / CSS
浅析HTML5 Landmark
Sep 11 HTML / CSS
关于canvas.toDataURL 在iOS运行失败的问题解决
Sep 16 HTML / CSS
纯CSS实现聊天框小尖角、气泡效果
Apr 04 #HTML / CSS
CSS3网格的三个新特性详解
Apr 04 #HTML / CSS
CSS类名支持中文命名的示例
Apr 04 #HTML / CSS
多重CSS背景动画实现方法示例
Apr 04 #HTML / CSS
CSS图片翻转动画技术详解(IE也实现了)
Apr 03 #HTML / CSS
使用CSS媒体查询(Media Queries)和JavaScript判断浏览器设备类型的方法
Apr 03 #HTML / CSS
css3实现input输入框颜色渐变发光效果代码
Apr 02 #HTML / CSS
You might like
在php中使用sockets:从新闻组中获取文章
2006/10/09 PHP
PHP 模板高级篇总结
2006/12/21 PHP
最令PHP初学者们头痛的十四个问题
2007/01/15 PHP
php下用cookie统计用户访问网页次数的代码
2010/05/09 PHP
php中XMLHttpRequest(Ajax)不能设置自定义的Referer的解决方法
2011/11/26 PHP
php中echo()和print()、require()和include()等易混淆函数的区别
2012/02/22 PHP
解析php利用正则表达式解决采集内容排版的问题
2013/06/20 PHP
解析php做推送服务端实现ios消息推送
2013/07/01 PHP
php中require和require_once的区别说明
2014/02/27 PHP
php随机抽奖实例分析
2015/03/04 PHP
smarty中改进truncate使其支持中文的方法
2016/05/30 PHP
在IE6下发生Internet Explorer cannot open the Internet site错误
2010/06/21 Javascript
基于jQuery实现鼠标点击导航菜单水波动画效果附源码下载
2016/01/06 Javascript
jQuery中常用动画效果函数(日常整理)
2016/09/17 Javascript
详解JavaScript权威指南之对象
2016/09/27 Javascript
JS常用函数和常用技巧小结
2016/10/15 Javascript
Bootstrap基本样式学习笔记之表单(3)
2016/12/07 Javascript
vue cli3.0结合echarts3.0与地图的使用方法示例
2019/03/26 Javascript
JS实现横向轮播图(初级版)
2020/06/24 Javascript
python3.6使用pymysql连接Mysql数据库
2018/05/25 Python
python画折线图的程序
2018/07/26 Python
Python ORM编程基础示例
2020/02/02 Python
英国旅游额外服务市场领导者:Holiday Extras(机场停车场、酒店、接送等)
2017/10/07 全球购物
size?瑞典:英国伦敦的球鞋精品店
2018/03/01 全球购物
施华洛世奇西班牙官网:SWAROVSKI西班牙
2019/06/06 全球购物
是否有自动比较结构的方法
2015/06/03 面试题
事业单位接收函
2014/01/10 职场文书
公司晚会主持词
2014/03/22 职场文书
小学生爱国演讲稿
2014/04/25 职场文书
公安个人四风问题对照检查及整改措施
2014/10/28 职场文书
2015年母亲节寄语
2015/03/23 职场文书
门店店长岗位职责
2015/04/14 职场文书
2016感恩父亲节主题广播稿
2015/12/18 职场文书
Python中的np.argmin()和np.argmax()函数用法
2021/06/02 Python
Python天气语音播报小助手
2021/09/25 Python
Mysql排查分析慢sql之explain实战案例
2022/04/19 MySQL