效果
🌟 在本文中,我们将深入探讨如何使用HTML和CSS来设计一个不仅功能完备,而且视觉吸引力十足的登录页面。从布局设计到动画效果,每一步都经过精心策划,以确保用户获得流畅且愉悦的登录体验。文章中不仅介绍了设计理念和实现方法,还提供了完整的源码,供读者学习和直接应用到自己的项目中。
完整代码
部分HTML
<html> <head> <title>java 登录界面</title> <meta name="keywords" content="java 登录界面" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="css/style.css" rel='stylesheet' type='text/css' /> </head> <body> <h1>欢迎进入java 登录界面</h1> <div class="registration"> <div class="form-info"> <form> <h2>xxx 登录 </h2> <input type="text" class="text" placeholder="用户名" required="" /> <input type="password" class="Password" placeholder="密码" required="" /> <div class="btn"><input type="submit" value="登录"></div> <div class="roundedOne"> <input type="checkbox" value="None" id="roundedOne" name="check" /> <label for="roundedOne"> </label> <p>记住密码</p> </div> </form> <div class="clear"> </div> </div> </div> </body> </html>
css:
/* reset */ html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,dl,dt,dd,ol,nav ul,nav li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline;} article, aside, details, figcaption, figure,footer, header, hgroup, menu, nav, section {display: block;} ol,ul{list-style:none;margin:0px;padding:0px;} blockquote,q{quotes:none;} blockquote:before,blockquote:after,q:before,q:after{content:'';content:none;} table{border-collapse:collapse;border-spacing:0;} /* start editing from here */ a{text-decoration:none;} .txt-rt{text-align:right;}/* text align right */ .txt-lt{text-align:left;}/* text align left */ .txt-center{text-align:center;}/* text align center */ .float-rt{float:right;}/* float right */ .float-lt{float:left;}/* float left */ .clear{clear:both;}/* clear float */ .pos-relative{position:relative;}/* Position Relative */ .pos-absolute{position:absolute;}/* Position Absolute */ .vertical-base{ vertical-align:baseline;}/* vertical align baseline */ .vertical-top{ vertical-align:top;}/* vertical align top */ nav.vertical ul li{ display:block;}/* vertical menu */ nav.horizontal ul li{ display: inline-block;}/* horizontal menu */ img{max-width:100%;} /*end reset*/ body { font-family:Verdana; background: url("../images/bg.jpg") no-repeat 0px 0px; text-align: center; background-size:cover; -webkit-background-size:cover; -moz-background-size:cover; -o-background-size:cover; height: 888px; } .wrap{ margin: 0 auto; width: 90%; } body a,form li,input[type="submit"],input[type="text"],.sixth-login input[type="submit"],.third-login input[type="submit"]{ transition: 0.1s all; -webkit-transition: 0.1s all; -moz-transition: 0.1s all; -o-transition: 0.1s all; } h1 { color: #FFFFFF; font-size: 3em; font-weight: 600; padding-top: 1em; } h2 { text-align: left; color: #4b86e7; font-size: 1.5em; font-weight: 300; margin-bottom: 20px; } .registration { background: #fff; width: 22%; margin: 2% auto 0; padding: 1.5em; } .form-info { width: 100%; margin: 0 auto; } input.text { outline: none; background: none; color: #999; width: 93%; padding: 12px; border: 1px solid#DDD; font-size: 1em; font-weight: 100; margin-bottom: 1.5em; box-shadow: 1px 1px 8px 2px #D6D6D6; -webkit-box-shadow: 1px 1px 8px 2px #D6D6D6; -moz-box-shadow: 1px 1px 8px 2px #D6D6D6; -o-box-shadow: 1px 1px 8px 2px #D6D6D6; } input[type="password"]{ outline: none; background: none; color: #999; width: 93%; padding: 12px; border: 1px solid#DDD; font-size: 1em; font-weight: 100; margin-bottom: 1.5em; box-shadow: 1px 1px 8px 2px #D6D6D6; -webkit-box-shadow: 1px 1px 8px 2px #D6D6D6; -moz-box-shadow: 1px 1px 8px 2px #D6D6D6; -o-box-shadow: 1px 1px 8px 2px #D6D6D6; } input[type="submit"] { outline: none; border: none; background: #73e74b; color: #fff; width: 100%; padding: 10px 25px; font-size: 1.2em; font-weight: 400; cursor: pointer; } input[type="submit"]:hover { background: #4fd0db; transition: 1s all; -webkit-transition: 1s all; -moz-transition: 1s all; -o-transition: 1s all; } input#slideThree { display: none; } .roundedOne p{ margin: 6px 0 0 36px; font-size: 13px; color: #999; width: 100px; } .btn{ float: right; } /*--checkbox--*/ .roundedOne { width: 28px; height: 28px; background: #fcfff4; background: -webkit-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%); background: -moz-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%); background: -o-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%); background: -ms-linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%); background: linear-gradient(top, #fcfff4 0%, #dfe5d7 40%, #b3bead 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fcfff4', endColorstr='#b3bead',GradientType=0 ); margin: 20px auto; -webkit-border-radius: 50px; -moz-border-radius: 50px; border-radius: 50px; -webkit-box-shadow: inset 0px 1px 1px white, 0px 1px 3px rgba(0,0,0,0.5); -moz-box-shadow: inset 0px 1px 1px white, 0px 1px 3px rgba(0,0,0,0.5); box-shadow: inset 0px 1px 1px white, 0px 1px 3px rgba(0,0,0,0.5); position: relative; left: 3px; top: -12px; float: left; } .roundedOne label { cursor: pointer; position: absolute; width: 20px; height: 20px; -webkit-border-radius: 50px; -moz-border-radius: 50px; border-radius: 50px; left: 4px; top: 4px; -webkit-box-shadow: inset 0px 1px 1px rgba(0,0,0,0.5), 0px 1px 0px rgba(255,255,255,1); -moz-box-shadow: inset 0px 1px 1px rgba(0,0,0,0.5), 0px 1px 0px rgba(255,255,255,1); box-shadow: inset 0px 1px 1px rgba(0,0,0,0.5), 0px 1px 0px rgba(255,255,255,1); background: -webkit-linear-gradient(top, #fff 0%, #fff 100%); background: -moz-linear-gradient(top, #fff 0%, #fff 100%); background: -o-linear-gradient(top, #fff 0%, #fff 100%); background: -ms-linear-gradient(top, #fff 0%, #fff 100%); background: linear-gradient(top, #fff 0%, #fff 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#222', endColorstr='#45484d',GradientType=0 ); } .roundedOne label:after { -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; filter: alpha(opacity=0); opacity: 0; content: ''; position: absolute; width: 16px; height: 16px; background: #4b86e7; background: -webkit-linear-gradient(top, #4b86e7 0%, #4b86e7 100%); background: -moz-linear-gradient(top, #4b86e7 0%, #4b86e7 100%); background: -o-linear-gradient(top, #4b86e7 0%, #4b86e7 100%); background: -ms-linear-gradient(top, #4b86e7 0%, #4b86e7 100%); background: linear-gradient(top, #4b86e7 0%, #4b86e7 100%); -webkit-border-radius: 50px; -moz-border-radius: 50px; border-radius: 50px; top: 2px; left: 2px; -webkit-box-shadow: inset 0px 1px 1px white, 0px 1px 3px rgba(0,0,0,0.5); -moz-box-shadow: inset 0px 1px 1px white, 0px 1px 3px rgba(0,0,0,0.5); box-shadow: inset 0px 1px 1px white, 0px 1px 3px rgba(0,0,0,0.5); } .roundedOne input[type=checkbox]:checked + label:after { -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; filter: alpha(opacity=100); opacity: 1; } input#roundedOne { display: none; } /*--/checkbox--*/ .strip { background: url("../images/strip.png") no-repeat 13px 8px; width: 349px; height: 22px; display: block; margin-bottom: 1em; position: relative; } .strip span { background: #FFFFFF; padding: 8px; border-radius: 50px; font-size: 18px; color: #DEDEDE; position: absolute; top: -55%; left: 45%; } /*--bottom-icons--*/ ul.bottom-sc-icons { list-style: none; margin: 0; padding: 0; } ul.bottom-sc-icons li { display: inline-block; margin: 25px 0 18px; } a.facebook { background: #34579b; color: #fff; padding: 18px 142px 18px 20px; font-size: 14px; border-radius: 3px; -webkit-border-radius: 3px; -moz-border-radius: 3px; -o-border-radius: 3px; -ms-border-radius: 3px; font-weight: 400; } a.twitter { background: #269df9; color: #fff; padding: 18px 151px 18px 16px; font-size: 14px; border-radius: 3px; -webkit-border-radius: 3px; -moz-border-radius: 3px; -o-border-radius: 3px; -ms-border-radius: 3px; font-weight: 400; } a.facebook img { vertical-align: middle; margin-right: 20px; } a.twitter img { vertical-align: middle; margin-right: 16px; } a.facebook:hover { background: #1B3E81; transition: 1s all; -webkit-transition: 1s all; -moz-transition: 1s all; -o-transition: 1s all; border-radius:0; } a.twitter:hover { background: #1E5681; transition: 1s all; -webkit-transition: 1s all; -moz-transition: 1s all; -o-transition: 1s all; border-radius:0; } /*--/bottom-icons--*/ .copy-rights { padding: 4em 0; } .copy-rights p { color:#fff; } .copy-rights p a { color:#fff; } .copy-rights p a:hover { color:#73e74b; } /*--start-responsive-design--*/ @media (max-width:1440px){ a.facebook { padding: 18px 132px 18px 20px; } a.twitter { padding: 18px 143px 18px 16px; } .strip span { left: 44%; } .registration { width: 24%; } } @media (max-width:1366px){ a.facebook { padding: 18px 120px 18px 16px; } a.twitter { padding: 18px 127px 18px 16px; } .strip { background: url("../images/strip.png") no-repeat 1px 8px; width: 323px; } } @media (max-width:1280px){ a.facebook { padding: 18px 95px 18px 16px; } a.twitter { padding: 18px 103px 18px 16px; } .strip { background: url("../images/strip.png") no-repeat 0 8px; width: 299px; background-size: 100%; } } @media (max-width:1024px){ .registration { width: 30%; } .strip { background: url("../images/strip.png") no-repeat 6px 8px; width: 308px; background-size: 97%; } body { font-family:Verdana; height: 675px; } .copy-rights { padding: 2em 0 1em; } a.facebook { padding: 18px 100px 18px 16px; } a.twitter { padding: 18px 105px 18px 16px; } } @media (max-width:768px){ body { font-family:Verdana; height: 929px; } .registration { width: 40%; } h1 { padding-top: 3em; } a.facebook { padding: 18px 105px 18px 16px; } a.twitter { padding: 18px 112px 18px 16px; } .strip { width: 308px; } } @media (max-width:640px){ .registration { width: 50%; } .strip { background: url("../images/strip.png") no-repeat 6px 8px; width: 311px; background-size: 97%; } a.facebook { padding: 18px 107px 18px 16px; } a.twitter { padding: 18px 114px 18px 16px; } } @media (max-width:480px){ .registration { width: 70%; } a.facebook { padding: 18px 121px 18px 16px; } a.twitter { padding: 18px 127px 18px 16px; } .strip { background: url("../images/strip.png") no-repeat 6px 8px; width: 325px; background-size: 98%; } } @media (max-width:320px){ h1 { font-size: 2em; padding-top: .5em; } .registration { width: 80%; padding: 1em; } input.text { width: 90%; margin-bottom: 1em; } input[type="password"] { width: 90%; } .roundedOne { margin: 12px auto 0; } .strip span { padding: 6px; font-size: 14px; top: -19%; left: 42%; } input[type="submit"] { padding: 8px 17px; font-size: 16px; } .strip { background: url("../images/strip.png") no-repeat 6px 8px; width: 243px; background-size: 97%; margin: 10px 0 7px; } a.facebook { padding: 18px 39px 18px 16px; } a.twitter { padding: 16px 45px 16px 15px; } body { font-family:Verdana; height: 545px; } .copy-rights { padding: 1.5em 0 1em; } }