We often need to control the hidden, transparent and other properties of some elements on the web page <style> .d1{ display: none; } .d2{ visibility: visible; } .d3{ opacity: 0; } </style> <div class="d1" onclick="clickEvent('display: none;')"></div> <div class="d2" onclick="clickEvent('visibility: hidden;')"></div> <div class="d3" onclick="clickEvent('opacity: 0;')"></div> <script type="text/javascript"> function clickEvent(type){ alert(type) } </script> display: none;
visibility: hidden;
opacity: 0;
rgb
z-index: -1
A little experiment You can try it yourself and play it. //html <div class="container"> <div class="target"> <p>I am target, and you?</p> </div> </div> // css <style> .container{ margin: 0 auto; width: 500px; min-height: 30px; background-color: skyblue; } .target{ width: 200px; height: 50px; line-height: 50px; text-align: center; margin: 0 auto; background-color: plum; color: #fff; transition: all linear 1s; cursor: pointer; } .clickBlock{ display: none; } .clickVisibility{ visibility: hidden; } .clickOpacity{ opacity: 0; } .clickRgba{ background-color: rgba(221, 160, 221, 0); } .clickZindex{ z-index: -1; position: absolute; } </style> // js const _target = document.getElementsByClassName("target")[0]; _target.onclick = (() => { let i = 1; // click times return () => { // _target.attributes.class.value += " clickBlock"; // _target.attributes.class.value += " clickVisibility"; // _target.attributes.class.value += " clickOpacity"; // _target.attributes.class.value += " clickRgba"; _target.attributes.class.value += " clickZindex"; console.log(`${i}th click`); i++; }})(); This is the end of this article about the differences between Display, Visibility and Opacity in CSS. For more information about CSS controlling hidden content, please search previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future! |
<<: Detailed steps to expand LVM disk in Linux
>>: How to implement mobile web page size adaptation
Explain the whole process of CLion from scratch. ...
*******************Introduction to HTML language (...
Table of contents Preface Project Design rear end...
introduce You Yuxi’s original words. vite is simi...
1. What is We can split the communication between...
Table of contents Preface What are constructible ...
margin:auto; + position: absolute; up, down, left...
Table of contents Preface 1. What is a lock? 2. L...
Method 1: Use the target event attribute of the E...
You can view the container logs through the docke...
1. Introduction Sometimes, after the web platform...
The most common, most commonly used and most gener...
1. The Linux server configures /etc/hosts.deny to...
Table of contents Preface What are dynamic proper...
Password Mode PDO::__construct(): The server requ...