時(shí)間:2023-09-08 13:24:01 | 來源:網(wǎng)站運(yùn)營
時(shí)間:2023-09-08 13:24:01 來源:網(wǎng)站運(yùn)營
HTML+CSS實(shí)現(xiàn)炫酷的登錄界面:<!DOCTYPE html><html lang="zh-CN"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width,initial-scale=1.0" /> <title>用戶登錄</title> <link rel="stylesheet" href="index_log.css" /> </head> <body> <div class="login"> <h2>用戶登錄</h2> <div class="login_box"> <!-- required就是不能為空 必須在css效果中有很大的作用 --> <input type="text" name='name' id='name' required /> <label for="name" >用戶名</label> </div> <div class="login_box"> <input type="password" name='pwd' id='pwd' required="required"> <label for="pwd">密碼</label> </div> <a href="javascript:void(0)"> 登錄 <span></span> <span></span> <span></span> <span></span> </a> </div> </body></html>
下面是CSS的代碼:*{ /*初始化 清除頁面元素的內(nèi)外邊距*/ padding: 0; margin: 0; /*盒子模型*/ box-sizing: border-box;}body { /*彈性布局 讓頁面元素垂直+水平居中*/ display: flex; justify-content: center; align-items: center; /*讓頁面始終占瀏覽器可視區(qū)域總高度*/ height: 100vh; /*背景漸變色*/ background: linear-gradient(#141e30,#243b55);}.login{ /*彈性布局 讓子元素稱為彈性項(xiàng)目*/ display: flex; /*讓彈性項(xiàng)目垂直排列 原理是改變彈性盒子的主軸方向 父元素就是彈性盒子 現(xiàn)在改變后的主軸方向是向下了*/ flex-direction: column; /*讓彈性項(xiàng)目在交叉軸方向水平居中 現(xiàn)在主軸的方向是向下 交叉軸的方向是與主軸垂直 交叉軸的方向是向右*/ align-items: center; width: 400px; padding: 40px; background-color: rgba(0, 0, 0, 0.2); box-shadow: 0 15px 25px rgba(0, 0, 0, 0.4);}.login h2{ color: #fff; margin-bottom: 30px;}.login .login_box { /*相對定位*/ position: relative; width: 100%;}.login .login_box input{ /*清除input框自帶的邊框和輪廓*/ outline: none; border: none; width: 100%; padding: 10px 0; margin-bottom: 30px; color: #fff; font-size: 16px; border-bottom: 1px solid #fff; /*背景顏色為透明色*/ background-color: transparent;}.login .login_box label{ position:absolute; top: 0 ; left: 0; padding: 10px 0; color: #fff; /*這個(gè)屬性的默認(rèn)值是auto 默認(rèn)是這個(gè)元素可以被點(diǎn)擊 但是如果我們寫了none 就是這個(gè)元素不能被點(diǎn)擊,就好像它可見但是不能用 可望而不可及*/ /*這個(gè)就是兩者的區(qū)別*/ pointer-events: none; /*加個(gè)過度*/ transition: all 0.5s;}/*: focus 選擇器是當(dāng)input獲得焦點(diǎn)是觸發(fā)的樣式 + 是相鄰兄弟選擇器 去找與input相鄰的兄弟label*//*:valid 選擇器是判斷input 框的內(nèi)容是否合法,如果合法會執(zhí)行下面的屬性代碼, 不合法就不會執(zhí)行,我們剛開始寫布局的時(shí)候給input框?qū)懥藃equired 我們刪掉看對比 當(dāng)沒有required的話 input框的值就會被認(rèn)為一直合法,所以一直都是下方的樣式, 但是密碼不會,密碼框的值為空,那么這句話就不合法,required不能為空 當(dāng)我們給密碼框?qū)扅c(diǎn)東西的時(shí)候才會執(zhí)行以下代碼*/.login .login_box input:focus + label,.login .login_box input:valid + label{ top: -20px; color: #03e9f4; font-size: 12px;}.login a{ /*overflow: hidden;*/ position: relative; padding: 10px 20px; color: #03e9f4; /*取消a表現(xiàn)原有的下劃線*/ text-decoration: none; /*同樣加個(gè)過渡*/ transition: all 0.5s;}.login a:hover { color: #fff; border-radius: 5px; background-color: #03e9f4; box-shadow: 0 0 5px #03e9f4,0 0 25px #03e9f4,0 0 50px #03e9f4,0 0 100px #03e9f4;}.login a span{ position: absolute;}.login a span:first-child { top: 0; left: -100%; width: 100%; height: 2px; /*to right 就是往右邊 下面的同理*/ background: linear-gradient(to right,transparent,#03e9f4); /*動(dòng)畫 名稱 時(shí)長 linear是勻速運(yùn)動(dòng) infinite是無限次運(yùn)動(dòng)*/ animation: move1 1s linear infinite;}.login a span:nth-child(2){ right: 0; top: -100%; width: 2px; height: 100%; background: linear-gradient(transparent,#03e6f4); /*這里多了個(gè)0.25s其實(shí)是延遲時(shí)間*/ animation: move2 1s linear 0.25s infinite;}.login a span:nth-child(3){ right: -100%; bottom: 0; width: 100%; height: 2px; background: linear-gradient(to left,transparent,#03e9f4); animation: move3 1s linear 0.5s infinite;}.login a span:last-child{ left: 0; bottom: -100%; width: 2px; height: 100%; background: linear-gradient(#03e9f4,transparent); animation: move4 1s linear 0.75s infinite;}/*寫一下動(dòng)畫 */@keyframes move1{ 0%{ left: -100%; } 50%, 100%{ left: 100%; }}@keyframes move2{ 0%{ top: -100%; } 50%, 100%{ top: 100%; }}@keyframes move3{ 0%{ right: -100%; } 50%, 100%{ right: 100%; }}@keyframes move4{ 0%{ bottom: -100%; } 50%, 100%{ bottom: 100%; }}
原文鏈接:HTML+CSS實(shí)現(xiàn)炫酷的登錄界面_m0_46625346的博客-CSDN博客
來源:CSDN
作者:罡罡同學(xué)
關(guān)鍵詞:界面,實(shí)現(xiàn)
客戶&案例
營銷資訊
關(guān)于我們
微信公眾號
版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。