用css3和jQuery制作精美的表单_html/css_WEB-ITnose

php中文网
发布: 2016-06-24 11:54:26
原创
1168人浏览过

用css3和jquery制作一个简单的精美表单

html代码如下:

 

表单大师AI
表单大师AI

一款基于自然语言处理技术的智能在线表单创建工具,可以帮助用户快速、高效地生成各类专业表单。

表单大师AI 74
查看详情 表单大师AI

Mask Your Input Forms and Make It Beauty


Too Plain


Fading The Label

                   


Sliding? Don't Worry

                   


css代码如下:

立即学习前端免费学习笔记(深入)”;

 

  * {     margin:0;     padding:0; } body {     text-align:center;     font-family:Georgia, "Times New Roman", Times, serif;     font-size:13px;     line-height:1.5em;     margin-top:8%;     background:#eaeaea; } input {     padding:7px;     border:5px solid #e0e0e0;     -webkit-border-radius:20px;     border-radius:20px;     -moz-border-radius:20px; } input:focus {     outline:none; } #container {     text-align:left;     width:700px;     margin-left:auto;     margin-right:auto; } .separator {     border-bottom:1px dashed #ccc;     margin-bottom:3px; } .title {     font-size:30px;     margin-bottom:1.5em;     font-weight:bold;     font-style:italic;     text-shadow:0 2px 0 #fff; } .small-title {     font-size:20px;     margin-bottom:0.5em;     font-weight:bold;     font-style:italic;     text-shadow:0 2px 0 #fff; } .username-label, .password-label, .username-label-sliding, .password-label-sliding {     position:absolute;     margin:9px 9px 9px 12px; } .username-sliding, .password-sliding {     width:150px; } a, a:visited, a:hover {     text-decoration: none;     color: #000; }

jQuery代码如下:

 

$(document).ready(function(){       $('.too-plain').focus(function(){           if($(this).val()=="Enter your email here")           {$(this).val("");}                      }).blur(function(){                              if($(this).val()=="")               {                   $(this).val('Enter your email here');                   }               });               $(".username-label,.password-label").animate({ opacity: "0.4" }).click(function(){                   var thisFor=$(this).attr("for");                   $('.'+thisFor).focus();                   })                   $(".username").focus(function(){                       $(".username-label").animate({opacity:"0"},"fast");                       if($(this).val()=="username")                       {                           $(this).val()=="";                           }                                              }).blur(function(){                           if($(this).val()=="")                           {                               $(this).val()=="username";                               $(".username-label").animate({opacity:"0.4"},"fast");                               }                           })             $('.password').focus(function(){                                  $(".password-label").animate({opacity:"0"},"fast");                 if($(this).val()=="password"){                     $(this).val()=="";                     }                                  }).blur(function(){                     if($(this).val()=="")                     {                         $(this).val()=="password";                         $('.password-label').animate({opacity:"0.4"},"fast");                          }                                          });                     $('.username-label-sliding,.password-label-sliding').animate({opacity:"0.4"}).click(function(){                         var thisFor=$(this).attr('for')                             $('.'+thisFor).focus();                         })                             $('.username-sliding').focus(function() {                                      $('.username-label-sliding').animate({ marginLeft: "7em" }, "fast");                                          if($(this).val() == "username")                             $(this).val() == "";                              }).blur(function() {                                          if($(this).val() == "") {                             $(this).val() == "username";                             $('.username-label-sliding').animate({ marginLeft: "12px" }, "fast");                         }                     });                              $('.password-sliding').focus(function() {                                      $('.password-label-sliding').animate({ marginLeft: "7em" }, "fast");                                          if($(this).val() == "password") {                             $(this).val() == "";                         }                     }).blur(function() {                                          if($(this).val() == "") {                             $(this).val() == "password";                             $('.password-label-sliding').animate({ marginLeft: "12px" }, "fast");                         }                 });       })

在firefox3.6,ie9,chrome中预览效果下图:

 

在ie7/8中预览效果如下图:

 

HTML速学教程(入门课程)
HTML速学教程(入门课程)

HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号