HTML+CSS+JS 实现登录注册界面[通俗易懂] | 您所在的位置:网站首页 › 登录页面的代码在html中 › HTML+CSS+JS 实现登录注册界面[通俗易懂] |
大家好,又见面了,我是你们的朋友全栈君。 文章目录案例一 滑动样式案例二 滑动样式案例三 动态样式案例四 普通样式案例五 滑动样式案例六 普通样式具体怎么获取呢?案例一 滑动样式login.html 代码语言:javascript复制 Login Sign Up Username Password True Name Submit Or, Sign In Sign In Username Password Sign In Or, Sign Up![]() main.js 代码语言:javascript复制var toggleBtns = document.querySelectorAll('.js-formToggle'); for(var i = 0; i < toggleBtns.length; i++){ toggleBtns[i].addEventListener("click",toggleForm); } var firstClick = true; function toggleForm(){ if(!firstClick){ document.querySelector('.js-imageAnimate').classList.toggle("animate"); document.querySelector('.js-imageAnimate').classList.toggle("animateOut"); document.querySelector('.js-panel_content').classList.toggle("animate"); document.querySelector('.js-panel_content').classList.toggle("animateOut"); } else{ firstClick = false; document.querySelector('.js-imageAnimate').classList.add("animate"); document.querySelector('.js-panel_content').classList.add("animate"); } }背景图: ![]() default.css 代码语言:javascript复制body, html{ font-family: Ariel, sans-serif; width:100%; height:100%; margin:0; padding:0; display:inline-block; } .page{ display:flex; flex-flow:row; flex-wrap:nowrap; align-items:center; justify-content:center; width:100%; height:100%; background-color: #0f95b0; } .panel{ display:inline-block; position:relative; } .panel_visible{ position:relative; overflow: hidden; } .panel_title{ margin-top: .5em; margin-bottom: 1.2em; } .panel_content{ padding: 20px; background-color: white; z-index:10; position:relative; } .panel_content-overlay{ position:absolute; top:0; left:100%; height:100%; } .panel_content.animate{ animation: movePanel 2s forwards ; } @keyframes movePanel{ 0%, 30%{ transform: translateX(0%); } 35%, 100%{ transform: translateX(-100%); } } .panel_content.animateOut{ animation: movePanelOut 2s forwards ; } @keyframes movePanelOut{ 0%, 30%{ transform: translateX(-100%); } 35%, 100%{ transform: translateX(0%); } } .panel_back{ position:absolute; z-index:0; top:50%; left: 0; width:110%; transform: translate(70%,-50%); } .panel_back.animate{ animation: move 2s forwards ; } @keyframes move{ 0%{ transform: translate(70%,-50%); z-index:0; } 15%{ transform: translate(140%,-50%); z-index:10; } 75%{ transform: translate(-120%,-50%); z-index:10; } 100%{ transform: translate(-50%,-50%); z-index:0; } } .panel_back.animateOut{ transform: translate(-50%,-50%); animation: moveOut 2s forwards ; } @keyframes moveOut{ 0%{ transform: translate(-50%,-50%); z-index:0; } 15%{ transform: translate(-120%,-50%); z-index:10; } 75%{ transform: translate(140%,-50%); z-index:10; } 100%{ transform: translate(70%,-50%); z-index:0; } } .panel_img{ width:100%; display:block; } /* Form */ .form{ box-sizing:border-box; } .form_label{ display:block; color: #3D3D3D; font-weight: 600; margin-bottom: 5px; } .form_input{ border-radius: 3px; background-color: #f2f2f2 ; box-shadow: 0px 2px 2px #D6D6D6; border:none; padding: 2%; margin-bottom: 15px; width: 250px; box-sizing:border-box; position:relative; } .form_input:focus{ box-shadow: none; outline-color: #0f95b0; } .form_input::after{ /* TODO: make this after portion work */ content: "👁️"; position:absolute; top: 0; left: 0; height: 50px; width: 50px; background-color: red; } .form_btn{ margin-top: 1.2em; margin-bottom: 2em; display:block; width:100%; background-color: #0f95b0; color: white; border:none; padding: .6em; text-transform: uppercase; font-weight: 500; font-size: 1.1em; border-radius: 3px; cursor: pointer; } .form_toggle{ background-color: transparent; border: none; padding: 0; margin:0; font-size: 1.1em; box-sizing: border-box; border-bottom: 1px solid transparent; cursor: pointer; } .form_toggle:hover{ border-bottom: 1px solid #0f95b0; } .form_toggle:focus{ outline: none; border-bottom: 1px solid #0f95b0; }效果图: ![]() ![]() style.css 代码语言:javascript复制*{ padding: 0; margin:0; box-sizing: border-box; font-family: 'Poppins',sans-serif; } /* 设置整个表单参数 (父盒子)*/ section { position: relative; min-height: 100vh; background: lightblue; display: flex; justify-content: center; align-items: center; padding: 20px; } section .container { position: relative; width: 800px; height: 500px; background: #fff; box-shadow: 0 15px 50px rgba(0, 0, 0, 0.1); overflow: hidden; } section .container .user{ position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; } /* 更改图片 (左侧)*/ section .container .imgBx{ position: relative; width: 50%; height: 100%; /* background: #fff; */ transition: .5s; } section .container .user .imgBx img{ position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; } /* 右侧表单盒子 */ section .container .user .formBx { position: relative; width: 50%; height: 100%; background: #fff; display: flex; justify-content: center; align-items: center; padding: 40px; transition: .5s; } /* h2 */ section .container .user .formBx form h2{ font-size: 18px; font-weight: 600; text-transform: uppercase;/*大小*/ letter-spacing: 2px;/* 间距*/ text-align: center; width: 100%; margin-bottom: 10px; color: #555; } /* 表单文字属性 */ section .container .user .formBx form input{ position: relative; width: 100%; padding: 10px; background: #f5f5f5; color: #333; border: none; outline:none; box-shadow:none; margin: 8px 0; font-size: 14px; letter-spacing:1px; font-weight: 300; } /* 为登录设置样式 */ section .container .user .formBx form input[type="submit"]{ max-width: 100px; background: #677eff; color:#fff; cursor:pointer; font-size: 14px; font-weight: 500; letter-spacing: 1px; transition: .5s; } /* 没有账号时 */ section .container .user .formBx form .signup{ position: relative; margin-top: 20px; font-size: 12px; letter-spacing: 1px; color: #555; text-transform: uppercase; font-weight: 300; } section .container .user .formBx form .signup a{ font-weight: 600; text-decoration: none; color: #677eff; } section .container .singupBx { pointer-events: none; } section .container.active .singupBx { pointer-events: initial; } section .container .singupBx .formBx { left: 100%; } section .container.active .singupBx .formBx { left: 0; } section .container .singupBx .imgBx { left: -100%; } section .container.active .singupBx .imgBx { left: 0; } section .container .singinBx .formBx { left: 0; } section .container.active .singinBx .formBx { left: 100%; } section .container .singinBx .imgBx { left: 0; } section .container.active .singinBx .imgBx { left: 100%; } @media (max-width: 991px) { section .container { max-width: 400px; } section .container .imgBx { display: none; } section .container .user .formBx { width: none; } }First.html 代码语言:javascript复制 登录![]() 没有账号?注册 注册已有账号?登录 ![]() img图片: favicon.ico ![]() 1.jpg ![]() 2.jpg ![]() 效果图: ![]() ![]() index.html 代码语言:javascript复制 Document![]() style.css 代码语言:javascript复制* { margin: 0; padding: 0; } body { height: 100vh; display: flex; justify-content: center; align-items: center; font-family: miaowu; background: linear-gradient(45deg, rgb(80, 150, 250), rgb(245, 189, 253)) fixed; } .container { position: relative; width: 70rem; } .container img { width: 70rem; } .switch span { color: #ccc; font-size: 1.4rem; cursor: pointer; } .switch span.active { color: rgb(181, 154, 254); } .panel { width: 30%; margin: 10rem 0 0; position: absolute; right: 0; top: 0; display: flex; justify-content: center; } .form { width: 12rem; margin: 3rem 0 0; } .form .input { position: relative; opacity: 1; height: 2rem; width: 100%; margin: 2rem 0; transition: .4s; } .input input { outline: none; width: 100%; border: none; border-bottom: .1rem solid rgb(181, 154, 254); position: relative; line-height: 35px; background: transparent; z-index: 1; } .input label { position: absolute; left: 0; top: 20%; font-size: 1.2rem; color: rgb(129, 101, 207); transition: .3s; } .input input:focus ~ label { top: -50%; font-size: .9rem; } .form span { display: block; color: rgb(110, 89, 167); font-size: .8rem; cursor: pointer; } .form button { border: none; outline: none; margin: 2.5rem 0 0; width: 100%; height: 3rem; border-radius: 3rem; background: linear-gradient(90deg, rgb(181, 154, 254), rgb(245, 189, 253)); box-shadow: 0 0 8px rgb(181, 154, 254); cursor: pointer; color: white; font-family: miaowu; } #live2dcanvas { border: 0 !important; }背景图: ![]() 效果图: ![]() ![]() 效果图: ![]() 效果图: ![]() ![]() login.html 代码语言:javascript复制 登录界面 LOGINstyle.css 代码语言:javascript复制body { margin: 0; padding: 0; background-image: url(../img/bglogin.png); /* 背景图片 */ background-repeat: no-repeat; /* 背景图片不重复 */ } #bigBox { margin: 0 auto; /* login框剧中 */ margin-top: 200px; /* login框与顶部的距离 */ padding: 20px 50px; /* login框内部的距离(内部与输入框和按钮的距离) */ background-color: #00000090; /* login框背景颜色和透明度 */ width: 400px; height: 300px; border-radius: 10px; /* 圆角边 */ text-align: center; /* 框内所有内容剧中 */ } #bigBox h1 { color: white; /* LOGIN字体颜色 */ } #bigBox .inputBox { margin-top: 50px; /* 输入框顶部与LOGIN标题的间距 */ } #bigBox .inputBox .inputText { margin-top: 20px; /* 输入框之间的距离 */ } #bigBox .inputBox .inputText span { color: white; /* icon颜色 */ } #bigBox .inputBox .inputText input { border: 0; /* 删除输入框边框 */ padding: 10px 10px; /* 输入框内的间距 */ border-bottom: 1px solid white; /* 输入框白色下划线 */ background-color: #00000000; /* 输入框透明 */ color: white; /* 输入字体的颜色 */ } #bigBox .loginButton { margin-top: 30px; /* 按钮顶部与输入框的距离 */ width: 150px; height: 25px; color: white; /* 按钮字体颜色 */ border: 0; /* 删除按钮边框 */ border-radius: 20px; /* 按钮圆角边 */ background-image: linear-gradient(to right, #b8cbb8 0%, #b8cbb8 0%, #b465da 0%, #cf6cc9 33%, #ee609c 66%, #ee609c 100%); /* 按钮颜色 */ }iconfont.css 代码语言:javascript复制@font-face { font-family: "iconfont"; src: url('iconfont.eot?t=1591106386397'); /* IE9 */ src: url('iconfont.eot?t=1591106386397#iefix') format('embedded-opentype'), /* IE6-IE8 */ url('data:application/x-font-woff2;base64,d09GMgABAAAAAAPkAAsAAAAACCgAAAOVAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCDBgqEDIM4ATYCJAMMCwgABCAFhG0HPBsEB1GUDUqS7IckiWBsgSKJ5iIQA3MI4geKAwAAlgIQD19j7f3dvUMtQRJNHn26aJJEYoiEToIQxUIheSdEpnsms/x+7VRC3R1ElWSaNOmT7YvvDbzSSY3SaIQIoTG0rs5YPKzkCKMdmFhnZl8Ihekb28ETv33fz7o4nDbF5zc4pzmmRl2AcUABjb0swQJKkHuIV7u0w15PoF6fKeXl/dOLUktBuwXiMPBUqZVSKTXZoVaolowt4kxdbTpJfpz6349fEyEhqWS078rBni1tfpx/3fAd/w7XLgJ7PAP4SWSMKynEbqlpRzUMjauqV0W1+uSqIqSxvP//+CxNUDX/8EiCqKKZjWCYCNNJsW1WLL5Bzlmzb65zFXW4U/ImqTtRmqq8rTVL84YCiXK964MkBwBChhC37GSmaAaSZCIxivE4l2FIEkKCE4+PJJNjXMSMJhepAICiEKKrGWaMhIBoAYhLZOh2Bu7SzZGtAqIe0SYcGUlQiUgCUTVo/TnJjVvc95HI5Yi3TFFIQg4HkA28Mz+KSzM0xiMcdSST3vj0UzjDecQXy46LKNurEblFc0L3gGbB7yd2/6rYfSSsEoO2lVGueUc76Qd5FBr4XjBRXGr52LLO3SgfmellnsiUfeLOjkZD4cMQHi4vxEFvmweWxo5OZvix0VJYMQTybB2X8TbsGqooxPqHm3j4sdDQ2N6Fh17hMYUVnLuDgqKukpbs4WGWHRlWt5QUdhL9OpNfZny4NlGbb7prFux5BkrDntnR4Yvm72lYnjz7vL23GnzeXB3LWuqPt09ct8c9GsyblVq+Zb7y8lN/4+H2amVv2PFX2y3g/ef9DBVFu3RqJVqzfyG7ZUnRuFSdi8KyWYY7O/KbDAlkCDr/xNbur7+lSyk2hFqBjZDU6IWsVj+yYMehosEUVNWag3pjDiY36MCqotRh1AdAaPUFSbNXyFr9IAv2Fyq6/UNVa/Ch3lbo52wwGJudLkYlaEG/QGCylCytdILsM/QeYsVJro+7QnaBF+Zn5rLRA0yRxxjgHr0FEQLiLIF92AzjOIOcsxCNzPgi+cbsLJW9aMZkSaljCUOKQBbQXoCAkUmRW1l0cp8/gzwPYgrXFFXpryDmBLWDeTPmWiAPRGmromu5xHnkWSAEAYRlEmAfDCg2QxmQl7cKIUPM8HsEchtmSTlqK5qZX5I83yqoR4/JkSJHUXMcuEDH2NoLTJSqBEslAAAA') format('woff2'), url('iconfont.woff?t=1591106386397') format('woff'), url('iconfont.ttf?t=1591106386397') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+ */ url('iconfont.svg?t=1591106386397#iconfont') format('svg'); /* iOS 4.1- */ } .iconfont { font-family: "iconfont" !important; font-size: 16px; font-style: normal; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } .icon-visible:before { content: "\e6a2"; } .icon-nickname:before { content: "\e6a0"; }效果图: ![]() 鉴于小伙伴们没有csdn积分,我把代码压缩成了一个压缩包,放在了gitee上面,需要的请点击下载 点击下载 发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/162713.html原文链接:https://javaforall.cn |
CopyRight 2018-2019 实验室设备网 版权所有 |