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
Problem: The partition where MySQL stores data fi...
This article describes the Mysql self-join query....
1. The first method is to start the local tomcat ...
MySQL is a relatively easy-to-use relational data...
Try installing via pip in a virtual environment: ...
First, let me introduce how to install PHP on Cen...
It is too troublesome to find the installation tu...
In the past few years, I have been moving back an...
Table of contents Environmental Description Insta...
Table of contents 1. Particle Effects 2. Load the...
Preface lvm (Logical Volume Manager) logical volu...
mysql basic data types Overview of common MySQL d...
Table of contents 2. Comma operator 3. JavaScript...
This article shares the installation and configur...
Due to the initial partitioning of the system, th...