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

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


慕的地6264312
浏览 842回答 1
1回答

慕田峪4524236

&nbsp;&nbsp; &nbsp;制作步骤:&nbsp;一, 引入prefixfree.js脚本&nbsp;下面代码中使用了CSS3无前缀脚本prefixfree.js,可以省去CSS3中前缀“-moz”、“-webkit”、“-o”、“-ms”。&nbsp;&nbsp;&nbsp;代码如下: &nbsp; &nbsp;<script type="text/javascript" &nbsp;charset="UTF-8" src="prefixfree.min.js"></script> &nbsp;&nbsp;&nbsp;二, <body>标签结构 &nbsp;&nbsp;&nbsp;代码如下: &nbsp; &nbsp;<body> &nbsp;<div &nbsp;class="content"> &nbsp;<form action="" method="post" &nbsp;class="login-form"> &nbsp;<div class="username"> &nbsp;<input type="text" &nbsp;name="username" placeholder="" autocomplete="on" /> &nbsp;<span &nbsp;class="user-icon icon">u</span> &nbsp;</div> &nbsp;<div &nbsp;class="password"> &nbsp;<input type="password" name="password" placeholder="" &nbsp;/> &nbsp;<span class="password-icon &nbsp;icon">p</span> &nbsp;</div> &nbsp;<div &nbsp;class="account-control"> &nbsp;<input type="checkbox" name="Remember me" &nbsp;id="Remember me" value="Remember me" checked="checked" /> &nbsp;<label &nbsp;for="Remember me" data-on="c" class="check"></label> &nbsp;<label &nbsp;for="Remember me" class="info">Remember me</label> &nbsp;<button &nbsp;type="submit">Login</button> &nbsp;</div> &nbsp;</form> &nbsp;</div> &nbsp;</body> &nbsp;&nbsp;&nbsp;三,CSS代码&nbsp; &nbsp;代码如下: &nbsp; &nbsp;body { &nbsp;background: &nbsp;url(bg.png); &nbsp;background-size: 100% &nbsp;100%; &nbsp;margin:0; &nbsp;padding:0;} &nbsp;.content &nbsp;{ &nbsp;width:600px; &nbsp;height:420px; &nbsp;margin:50px auto; &nbsp;} &nbsp;.login-form &nbsp;{ &nbsp;width:400px; &nbsp;height:177px; &nbsp;margin:70px auto &nbsp;0; &nbsp;padding-top:73px; &nbsp;position:relative; &nbsp;background-image:-*-linear-gradient(top,rgb(255,255,255),rgb(242,242,242)); &nbsp;box-shadow:0 &nbsp;3px 3px rgba(21,62,78,0.8); &nbsp;} &nbsp;.login-form:before &nbsp;{ &nbsp;content:""; &nbsp;position:absolute; &nbsp;top:-50px; &nbsp;left:150px; &nbsp;width:102px; &nbsp;height:102px; &nbsp;padding:2px; &nbsp;border:1px &nbsp;solid rgb(216,216,219); &nbsp;background:#fff url("profilepicture.jpg") no-repeat &nbsp;2px 2px; &nbsp;} &nbsp;.not-registered &nbsp;{ &nbsp;position:absolute; &nbsp;color:rgb(153,153,153); &nbsp;font-weight:bold; &nbsp;font-size:13px; &nbsp;top:calc(100% &nbsp;+ &nbsp;20px); &nbsp;background-color:rgb(255,255,255); &nbsp;width:400px; &nbsp;height:46px; &nbsp;margin:0 &nbsp;auto; &nbsp;line-height:46px; &nbsp;text-align: center; &nbsp;box-shadow:0 3px 3px &nbsp;rgba(21,62,78,0.8); &nbsp;} &nbsp;.not-registered a &nbsp;{ &nbsp;margin-left:5px; &nbsp;text-decoration: &nbsp;none; &nbsp;color:rgb(52,119,182); &nbsp;cursor: pointer; &nbsp;} &nbsp;.login-form div &nbsp;{ &nbsp;width:216px; &nbsp;height:28px; &nbsp;margin:20px &nbsp;auto; &nbsp;position:relative; &nbsp;line-height:28px; &nbsp;border:none; &nbsp;} &nbsp;.login-form &nbsp;.user-icon, &nbsp;.login-form .password-icon &nbsp;{ &nbsp;display:inline-block; &nbsp;font-family: &nbsp;'loginform-icon'; &nbsp;font-size:15px; &nbsp;text-align:center; &nbsp;line-height:28px; &nbsp;color:rgb(153,153,153); &nbsp;position:absolute; &nbsp;left:1px; &nbsp;top:1px; &nbsp;background-color:rgb(255,255,255); &nbsp;border:none; &nbsp;border-right:1px &nbsp;solid rgb(229,229,232); &nbsp;width:30px; &nbsp;height:28px; &nbsp;transition: all 300ms &nbsp;linear; &nbsp;} &nbsp;.login-form .username input, .login-form .password input &nbsp;{ &nbsp;height:100%; &nbsp;width:calc(100% - &nbsp;40px); &nbsp;padding-left:40px; &nbsp;border-radius:2px; &nbsp;border:1px &nbsp;solid; &nbsp;border-color:rgb(229,229,232) rgb(220,220,221) rgb(213,213,213) &nbsp;rgb(220,220,221); &nbsp;display:block; &nbsp;transition: all 300ms &nbsp;linear; &nbsp;}</p> <p>.login-form .icon:before, .login-form &nbsp;.icon:after &nbsp;{ &nbsp;content:""; &nbsp;position:absolute; &nbsp;top:10px; &nbsp;left:30px; &nbsp;width:0; &nbsp;height:0; &nbsp;border:4px &nbsp;solid transparent; &nbsp;border-left-color:rgb(255,255,255); &nbsp;} &nbsp;.login-form &nbsp;.icon:before { &nbsp;top:9px; &nbsp;border:5px solid &nbsp;transparent; &nbsp;border-left-color:rgb(229,229,232); &nbsp;} &nbsp;.login-form &nbsp;.username input:focus, .login-form .password input:focus &nbsp;{ &nbsp;border-color:rgb(69,153,228); &nbsp;box-shadow:0 0 2px 1px &nbsp;rgb(200,223,244); &nbsp;} &nbsp;.login-form .username input:focus + span, .login-form &nbsp;.password input:focus + span &nbsp;{ &nbsp;background:-*-linear-gradient(top,rgb(255,255,255),rgb(245,245,245)); &nbsp;color:rgb(51,51,51); &nbsp;} &nbsp;.login-form &nbsp;.username input:focus + span:after, .login-form .password input:focus + &nbsp;span:after { &nbsp;border-left-color:rgb(250,250,250); &nbsp;}</p> &nbsp;<p>.login-form .account-control label &nbsp;{ &nbsp;margin-left:24px; &nbsp;font-size:12px; &nbsp;font-family: Arial, Helvetica, &nbsp;sans-serif; &nbsp;cursor:pointer; &nbsp;} &nbsp;.login-form button[type="submit"] &nbsp;{ &nbsp;color:#fff; &nbsp;font-weight:bold; &nbsp;float:right; &nbsp;width:68px; &nbsp;height:30px; &nbsp;position:relative; &nbsp;background:-*-linear-gradient(top,rgb(74,162,241),rgb(52,119,182)) &nbsp;1px 0 no-repeat, &nbsp;-*-linear-gradient(top,rgb(52,118,181),rgb(36,90,141)) left &nbsp;top no-repeat; &nbsp;background-size:66px 28px,68px &nbsp;29px; &nbsp;border:none; &nbsp;border-top:1px solid &nbsp;rgb(52,118,181); &nbsp;border-radius:2px; &nbsp;box-shadow:inset 0 1px 0 &nbsp;rgb(86,174,251); &nbsp;text-shadow:0 1px 1px rgb(51,113,173); &nbsp;transition: all &nbsp;200ms linear; &nbsp;} &nbsp;.login-form button[type="submit"]:hover { &nbsp;text-shadow:0 &nbsp;0 2px rgb(255,255,255); &nbsp;box-shadow:inset 0 1px 0 rgb(86,174,251),0 0 10px 3px &nbsp;rgba(74,162,241,0.5); &nbsp;} &nbsp;.login-form button[type="submit"]:active &nbsp;{ &nbsp;background:-*-linear-gradient(top,rgb(52,119,182),rgb(74,162,241)) 1px 0 &nbsp;no-repeat, &nbsp;-*-linear-gradient(top,rgb(52,118,181),rgb(36,90,141)) left top &nbsp;no-repeat; &nbsp;}</p> <p>.login-form .account-control input &nbsp;{ &nbsp;width:0px; &nbsp;height:0px; &nbsp;} &nbsp;.login-form label.check &nbsp;{ &nbsp;position:absolute; &nbsp;left:0; &nbsp;top:50%; &nbsp;margin:-8px &nbsp;0; &nbsp;display:inline-block; &nbsp;width:16px; &nbsp;height:16px; &nbsp;line-height: &nbsp;16px; &nbsp;text-align:center; &nbsp;border-radius:2px; &nbsp;background:-*-linear-gradient(top,rgb(255,255,255),rgb(246,246,246)) &nbsp;1px 1px no-repeat, &nbsp;-*-linear-gradient(top,rgb(227,227,230),rgb(165,165,165)) &nbsp;left top no-repeat; &nbsp;background-size:14px 14px,16px 16px; &nbsp;} &nbsp;.login-form &nbsp;.account-control input:checked + label.check:before &nbsp;{ &nbsp;content:attr(data-on); &nbsp;font-family:loginform-icon; &nbsp;} &nbsp;@font-face &nbsp;{ &nbsp;font-family: 'loginform-icon'; &nbsp;src: &nbsp;url("font/loginform-icon.eot"); &nbsp;src: url("font/loginform-icon.eot?#iefix") &nbsp;format('embedded-opentype'), &nbsp;url("font/loginform-icon.woff") &nbsp;format('woff'), &nbsp;url("font/loginform-icon.ttf") &nbsp;format('truetype'), &nbsp;url("font/loginform-icon.svg#loginform-icon") &nbsp;format('svg'); &nbsp;font-weight: normal; &nbsp;font-style: normal; &nbsp;} &nbsp;&nbsp;&nbsp;OK,制作完成!自己动手试试吧。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

CSS3