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
<br />In previous tutorials of 123WORDPRESS....
First, setInterval is encapsulated as a Hook 👇 im...
1.MySQL replication concept It means transferring...
Recently I used MySQL to export table data to an ...
1. Introduction to gitlab Gitlab official address...
Two examples of the use of the a tag in HTML post...
question In LINUX, periodic tasks are usually han...
Preface: Docker is an open source application con...
You know that without it, the browser will use qui...
In this section, we will learn about list element...
I think editors are divided into two categories, ...
In the UI cutting process, the page is often comp...
1. Enter the command mysqld --skip-grant-tables (...
This article uses an example to illustrate the pa...
Click here to return to the 123WORDPRESS.COM HTML ...