Example of using CSS filter to write mouse over effect

Example of using CSS filter to write mouse over effect

Use CSS filter to write mouse over effect

<div class="filter-div">
  <img class="filter-img" src="../assets/images/01list.png"/>
</div>
<style>
    .filter-div {
      width: 67px;
      height: 50px;
      background: #fff;
      &:hover {
          background: #5d7aae;
        }
    }
    .filter-img {
      width: 67px;
      height: 50px;
      &:hover {
         filter: brightness(100);
      }
    }
</style>

No Hover before the mouse is placed

After the mouse is placed, there is a Hover

The CSS filter:brightness(100) is used here to apply a linear multiplication to the image, making it appear brighter or darker. If the value is 0% or 0, the image will be completely black. A value of 100% results in no change to the image. Other values ​​correspond to a linear multiplier effect. Values ​​over 100% are possible, and the image will be brighter than before. If no value is set, the default is 1. If you want to dye the image white, the value is 100.

Because the traditional hover method changes the src of img, the image will flash white when it is hovered for the first time, because the image needs to be reloaded. The advantage of this method is that the image only needs to be loaded once. Of course, this method also has limitations. You are welcome to correct me.

This is the end of this article about using CSS filters to write examples of mouse rollover effects. For more relevant CSS filter mouse rollover 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!

<<:  VMware Workstation Pro 16 License Key with Usage Tutorial

>>:  mysql determines whether the current time is between the start and end time and the start and end time are allowed to be empty

Recommend

Calculation of percentage value when the css position property is absolute

When position is absolute, the percentage of its ...

Detailed explanation of three ways to set borders in HTML

Three ways to set borders in HTML border-width: 1...

Detailed explanation of EXT series file system formats in Linux

Linux File System Common hard disks are shown in ...

In-depth analysis of MySQL explain usage and results

Preface In daily work, we sometimes run slow quer...

Share a Markdown editor based on Ace

I think editors are divided into two categories, ...

The latest graphic tutorial of mysql 8.0.16 winx64 installation under win10

In order to download this database, it takes a lo...

How to implement call, apply and bind in native js

1. Implement call step: Set the function as a pro...

Linux kernel device driver character device driver notes

/******************** * Character device driver**...

mysql5.6.8 source code installation process

Kernel: [root@opop ~]# cat /etc/centos-release Ce...

Introduction to the use of MySQL performance stress benchmark tool sysbench

Table of contents 1. Introduction to sysbench #Pr...

js memory leak scenarios, how to monitor and analyze them in detail

Table of contents Preface What situations can cau...

Learn Hyperlink A Tag

ask: I have styled the hyperlink using CSS, but i...

Method of building docker private warehouse based on Harbor

Table of contents 1. Introduction to Harbor 1. Ha...