I believe some people have seen this picture of covering their eyes when entering the password on B station Here we use :focus-within to play a bit The layout is like this There is a ctn outside which can be ignored, it is just a fixed position in the center The "suo" icon in xPassword is hidden before clicking on it. The "r6m" after the xPassword is displayed at this time When we click xPassword, the first image of the same level 'r6m' is hidden At the same time, a picture of 'suo' in xPassword is displayed! At this time, you enter the password and I pretend not to see it. <div class="ctn"> <div class="xPassword"> <input type="password" placeholder="Please enter your password" 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 h2 { 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%; } //The above are worthless and can be ignored. The following two are the key points. xPassword:focus-within ~ img { display: none; } .xPassword:focus-within img { display: block; } This is the end of this article about the fun of :focus-within in CSS. For more relevant CSS :focus-within content, please search 123WORDPRESS.COM’s previous articles or continue to browse the related articles below. I hope that everyone will support 123WORDPRESS.COM in the future! |
<<: Solution to the problem that Xshell cannot connect to the virtualBox virtual machine
>>: Introduction to TypeScript interfaces
Table of contents First step installation Step 2:...
1: Docker private warehouse installation 1. Downl...
Problem Reproduction Alibaba Cloud Server, using ...
Here we introduce the centos server with docker i...
Reference: MySQL character set summary utf8mb4 ha...
11. Use JavaScript to create page effects 11.1 DO...
Table of contents 1. Add packaging command 2. Run...
Why does CSS have a cascading mechanism? Because ...
Static files Nginx is known for its high performa...
Table of contents Basic usage of Promise: 1. Crea...
The simple installation configuration of mysql5.7...
Table of contents Preface 1. Install scp2 2. Conf...
1 Introduction Kong is not a simple product. The ...
Table of contents Why use day.js Moment.js Day.js...
1. Experimental Environment serial number project...