這篇文章主要為大家展示了css中:focus-within怎么用,內容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶大家一起來研究并學習一下“css中:focus-within怎么用”這篇文章吧。
成都創(chuàng)新互聯(lián)-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設、高性價比周村網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式周村網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設找我們,業(yè)務覆蓋周村地區(qū)。費用合理售后完善,十余年實體公司更值得信賴。
這里我們用:focus-within玩一把
布局是這樣的
外面有一個ctn 可以忽略,就是一個居中固定位置而已
xPassword在沒點擊之前里面的“suo”這個圖是隱藏的
xPassword 同級屁股后的“r6m”此時是顯示的
當我們一點擊xPassword后同級第一張圖‘r6m’隱藏
:focus-within ~ img的 ~ 這個符號是同級屁股后第一個的意思
同時xPassword里面的一張圖‘suo’的這個display為顯示!這時就成了你輸密碼我就裝作看不見
<div class="ctn"> <div class="xPassword"> <input type="password" placeholder="請輸入密碼" 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%; } //以上毫無價值,可以忽略,下方兩個才是重點 .xPassword:focus-within ~ img { display: none; } .xPassword:focus-within img { display: block; }
以上就是關于“css中:focus-within怎么用”的內容,如果改文章對你有所幫助并覺得寫得不錯,勞請分享給你的好友一起學習新知識,若想了解更多相關知識內容,請多多關注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
文章名稱:css中:focus-within怎么用
文章地址:http://www.sd-ha.com/article18/jjcidp.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設計公司、Google、網(wǎng)站排名、網(wǎng)站制作、網(wǎng)站維護、動態(tài)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)