這篇文章主要為大家展示了css中:focus-within怎么用,內(nèi)容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶大家一起來研究并學(xué)習(xí)一下“css中:focus-within怎么用”這篇文章吧。
成都創(chuàng)新互聯(lián)-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價(jià)比周村網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式周村網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋周村地區(qū)。費(fèi)用合理售后完善,十余年實(shí)體公司更值得信賴。
這里我們用:focus-within玩一把
布局是這樣的
外面有一個(gè)ctn 可以忽略,就是一個(gè)居中固定位置而已
xPassword在沒點(diǎn)擊之前里面的“suo”這個(gè)圖是隱藏的
xPassword 同級(jí)屁股后的“r6m”此時(shí)是顯示的
當(dāng)我們一點(diǎn)擊xPassword后同級(jí)第一張圖‘r6m’隱藏
:focus-within ~ img的 ~ 這個(gè)符號(hào)是同級(jí)屁股后第一個(gè)的意思
同時(shí)xPassword里面的一張圖‘suo’的這個(gè)display為顯示!這時(shí)就成了你輸密碼我就裝作看不見
<div class="ctn"> <div class="xPassword"> <input type="password" placeholder="請(qǐng)輸入密碼" class="input"> <img src="http://suo.im/5UnnjN" alt=""> </div> <img src="http://r6m.cn/csAC" alt=""> </div>
.ctn { position: relative; width: 318px; margin: 100px auto; height: 370px; padding: 20px; box-sizing: border-box; background: #fff; z-index: 10; box-shadow: 0 0 15px #cfcfcf; } .ctn h3 { font-size: 20px; font-weight: bold; margin-bottom: 30px; } .ctn input { padding: 10px; width: 100%; border: 1px solid #e9e9e9; border-radius: 2px; outline: none; box-sizing: border-box; font-size: 16px; } img { position: absolute; top: -23%; left: 50%; width: 80px; height: auto; transform: translate(-50%, 0); } .xPassword img { display: none; width: 103px; height: auto; top: -26%; } //以上毫無價(jià)值,可以忽略,下方兩個(gè)才是重點(diǎn) .xPassword:focus-within ~ img { display: none; } .xPassword:focus-within img { display: block; }
以上就是關(guān)于“css中:focus-within怎么用”的內(nèi)容,如果改文章對(duì)你有所幫助并覺得寫得不錯(cuò),勞請(qǐng)分享給你的好友一起學(xué)習(xí)新知識(shí),若想了解更多相關(guān)知識(shí)內(nèi)容,請(qǐng)多多關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
文章名稱:css中:focus-within怎么用
文章地址:http://bm7419.com/article18/jjcidp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)公司、Google、網(wǎng)站排名、網(wǎng)站制作、網(wǎng)站維護(hù)、動(dòng)態(tài)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)