1. IntroductionWhen writing animation effects for front-end pages, the filter attribute will be used more or less. Since there are too many attribute values, this article is used to organize and record its related information. II. IntroductionThe filter attribute defines a visual effect on an element (usually ). The property values are as follows:
Note: Filters are usually expressed as percentages (such as 75%), but can also be expressed as decimals (such as 0.75). 3. Demonstration Code<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> .container { margin: 4rem auto; width: 100%; height: auto; text-align: center; } .box { display: inline-block; margin: 1rem; } .box ul { margin: 0; padding: 0; list-style: none; text-align: left; } .box ul li { margin: .25rem 0; padding: .25rem; cursor: pointer; } .box ul li:hover { background-color: #eee; } ul li.active { background-color: #eee; } .box img { width: 260px; height: 260px; } </style> </head> <body> <div class="container"> <h3>Click on the left side to display the properties</h3> <div class="box"> <ul> <li data-p="blur(5px)">filter: blur(5px)</li> <li data-p="brightness(.5)">filter: brightness(.5)</li> <li data-p="contrast(.5)">filter: contrast(.5)</li> filter: grayscale(1) <li data-p="hue-rotate(90deg)">filter: hue-rotate(90deg)</li> <li data-p="invert(.4)">filter: invert(.4)</li> <li data-p="opacity(.4)">filter: opacity(.4)</li> filter: saturate(.5) <li data-p="sepia(.5)">filter: sepia(.5)</li> </ul> </div> <div class="box"> <div class="origin"> <img src="upload/2022/web/87c01ec7gy1frmmmwb3anj21hc0u0b2a.jpg" alt=""> </div> <div>Original image</div> </div> <div class="box"> <div id="filter"> <img src="upload/2022/web/87c01ec7gy1frmmmwb3anj21hc0u0b2a.jpg" alt=""> </div> <div id="info">Effect diagram</div> </div> </div> <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script> <script> $(function() { let $lis = $("li"); $lis.on("click", function() { $lis.removeClass("active"); let p = $(this).addClass("active").data("p"); $("#filter").css({"filter": p}); $("#info").text("filter: " + p); }); }); </script> </body> </html> The above is the detailed introduction to the use of CSS3 filter attributes. For more information about CSS3 filter attributes, please pay attention to other related articles on 123WORDPRESS.COM! |
>>: Pygame code to make a snake game
Busybox: A Swiss Army knife filled with small com...
Table of contents Purpose Experimental environmen...
Environment: VMware VCSA 6.7 (VMware-VCSA-all-6.7...
Table of contents Multi-application deployment 1-...
1. Install a virtual machine (physical machine) Y...
1. Problem Multiple floating elements cannot expa...
This is an enhanced version. The questions and SQ...
1. Docker Compose Overview Compose is a tool for ...
Business requirements One of the projects I have ...
Detailed explanation of JDBC database link and re...
Table of contents Purpose Module Installation Bas...
I believe everyone has played scratch tickets. Wh...
Preface PC Server has developed to this day and h...
Table of contents 1. unzip command 1.1 Syntax 1.2...
1. overflow:hidden overflow hidden If overflow:hi...