您好,登錄后才能下訂單哦!
這篇文章給大家分享的是有關(guān)HTML+CSS怎么實(shí)現(xiàn)動(dòng)態(tài)背景登錄頁(yè)面的內(nèi)容。小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過(guò)來(lái)看看吧。
1. 實(shí)現(xiàn)背景圖片的動(dòng)態(tài)變換
首先在HTML頁(yè)面body板塊中,添加圖片div,代碼如下:
<body> <div class="bgk"> <div class="bgk-image" style="background-image: url('${pageContext.request.contextPath}/img/1.jpg')"></div> <div class="bgk-image" style="background-image: url('${pageContext.request.contextPath}/img/2.jpg')"></div> <div class="bgk-image" style="background-image: url('${pageContext.request.contextPath}/img/3.jpg')"></div> <div class="bgk-image" style="background-image: url('${pageContext.request.contextPath}/img/4.jpg')"></div> </body>
再對(duì)圖片進(jìn)行css設(shè)計(jì)。你要對(duì)圖片進(jìn)行大小定位,那么以下代碼肯定要首先編寫(xiě):
`.bgk { margin: auto; position: absolute; width: 1366px; height: 672px; overflow: hidden; /*溢出部分隱藏*/ }`
位置設(shè)定ok以后,那么再對(duì)里面的圖片進(jìn)行設(shè)置。為了使圖片能足夠大覆蓋頁(yè)面,則代碼必須有 background-size: cover;
要實(shí)現(xiàn)動(dòng)態(tài)效果,那么你的css代碼中必須有動(dòng)畫(huà)的設(shè)計(jì):
-webkit-animation-name: kenburns; /*-animation-name:為@keyframes 動(dòng)畫(huà)規(guī)定名稱,必須與-animation-duration同時(shí)使用,否則無(wú)動(dòng)畫(huà)效果*/ animation-name: kenburns; /*或者:后面值為需要綁定到選擇器上的keyframe名稱*/ -webkit-animation-duration: 16s; /*定義動(dòng)畫(huà)完成一個(gè)周期所需時(shí)間*/ animation-duration: 16s; -webkit-animation-timing-function: linear; /*規(guī)定動(dòng)畫(huà)從頭到尾以相同速度播放,還有其他幾個(gè)速度值*/ animation-timing-function: linear; -webkit-animation-iteration-count: infinite; /*規(guī)定動(dòng)畫(huà)播放次數(shù),infinite為無(wú)限次*/ animation-iteration-count: infinite; -webkit-transform: scale(1.2); /*規(guī)定動(dòng)畫(huà)的縮放特效,scale:規(guī)定2D縮放*/ transform: scale(1.2); -webkit-filter: blur(10px); /*定義圖片的模糊程度,顯示為毛玻璃效果*/ filter: blur(10px);
在綁定每個(gè)子元素選擇器,有幾張圖片就綁定幾個(gè)選擇器:
.bgk-image:nth-child(1) { -webkit-animation-name: kenburns-1; /*選擇器上的名稱*/ animation-name: kenburns-1; z-index: 3; /*動(dòng)畫(huà)堆疊順序,值越大表示越先播放,離用戶越近*/ } .bgk-image:nth-child(2) { -webkit-animation-name: kenburns-2; animation-name: kenburns-2; z-index: 2; } .bgk-image:nth-child(3) { -webkit-animation-name: kenburns-3; animation-name: kenburns-3; z-index: 1; } .bgk-image:nth-child(4) { -webkit-animation-name: kenburns-4; animation-name: kenburns-4; z-index: 0; }
創(chuàng)建好選擇器以后,你就可以預(yù)覽你的動(dòng)態(tài)背景圖片變換了
2. 對(duì)登錄表單的設(shè)計(jì)
在之前HTML頁(yè)面中繼續(xù)添加一個(gè)表單
<div class="form_login_div"> <form class="form_login" action="" method="post"> <label class="login_title">登錄您的賬戶</label> <label class="username">用戶名</label><input class="input_username" id="input_username" type="text" name="username" placeholder="郵箱/手機(jī)號(hào)"/> <label class="password">密 碼</label><input class="input_password" id="input_password" type="password" name="password" placeholder="請(qǐng)輸入密碼"/> <input type="submit" value="登錄"/><br/> </form> </div>
添加完表單之后,就要進(jìn)行表單的樣式設(shè)計(jì)。首先你得對(duì)表單規(guī)定一個(gè)圈子,限制它的寬度和高度
.form_login{ margin: auto; width:700px; height: 480px; top: 90px; left: 333px; position: absolute; border-radius: 15px; background: rgba(216,216,216,0.5); /*設(shè)置form表單透明度*/ text-align: center; overflow: hidden; }
然后對(duì)表單里面的各個(gè)label進(jìn)行定位和樣式設(shè)計(jì),這里可以自由設(shè)計(jì)。
對(duì)輸入框的設(shè)計(jì),我只貼出主要樣式代碼
outline:none; /*outline (輪廓)是繪制于元素周?chē)囊粭l線,位于邊框邊緣的外圍,可起到突出元素的作用。*/ border:1px solid rgba(0,0,0,.49); /*輸入框邊框的大小,實(shí)線,rgba(red,green,blue,a為透明度),透明度處于0-1之間*/ -webkit-background-clip: padding-box; /*background-clip 規(guī)定背景的繪制區(qū)域,padding-box為內(nèi)容被裁減到內(nèi)邊距框*/ background-clip: padding-box; background:rgba(216,216,216,0.4) ; border-radius:6px; /*對(duì)輸入框進(jìn)行圓角*/ padding:7px; /*輸入框中光標(biāo)位置*/
當(dāng)聚焦輸入框的時(shí)候,可以增加一點(diǎn)絢麗色彩
.form_login input[type="text"]:focus,input[type="password"]:focus{ -webkit-transition:border linear .2s,-webkit-box-shadow linear .5s; /*對(duì)邊框顏色的逐步過(guò)渡高亮顯示,后面是對(duì)陰影的逐步過(guò)渡*/ border-color:rgba(255,128,0,.75); }
最后進(jìn)行提交按鈕的設(shè)計(jì)
text-shadow:0px -1px 0px #5b6ddc; /*文字陰影設(shè)置*/ outline:none; border:1px solid rgba(0,0,0,0.49); /*按鈕邊框顏色與透明度設(shè)置*/ -webkit-background-clip: padding-box; /*規(guī)定內(nèi)容的繪制區(qū)域,padding-box為內(nèi)邊框距*/ background-clip: padding-box; border-radius:6px; cursor:pointer; /*光標(biāo)形狀,pointer為一只手的形狀*/ background-color:#768ee4; /*按鈕背景顏色*/
當(dāng)鼠標(biāo)放在提交按鈕上面時(shí),你可以適當(dāng)進(jìn)行一些動(dòng)畫(huà)效果設(shè)計(jì)
.form_login input[type="submit"]:hover{ background-color:#5f73e9; background-image:-webkit-linear-gradient(bottom,#5f73e9 0%,#859bef 100%); background-image:-moz-linear-gradient(bottom,#5f73e9 0%,#859bef 100%); background-image:-ms-linear-gradient(bottom,#5f73e9 0%,#859bef 100%); background-image:-o-linear-gradient(bottom,#5f73e9 0%,#859bef 100%); -webkit-box-shadow: inset 0px 1px 0px #aab9f4; /*當(dāng)鼠標(biāo)放在按鈕上個(gè)時(shí)邊框的陰影*/ box-shadow: inset 0px 1px 0px #aab9f4; margin-top:22px; }
最后整個(gè)設(shè)計(jì)完成,你可以看見(jiàn)你最終的效果了
感謝各位的閱讀!關(guān)于“HTML+CSS怎么實(shí)現(xiàn)動(dòng)態(tài)背景登錄頁(yè)面”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。