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

How to remove the underline of a hyperlink using three simple examples

To remove the underline of a hyperlink, you need t...

Detailed process of installing Presto and connecting Hive in Docker

1. Introduction Presto is an open source distribu...

Detailed explanation of JavaScript function this pointing problem

Table of contents 1. The direction of this in the...

How to install Odoo12 development environment on Windows 10

Preface Since many friends say they don’t have Ma...

Summary of the use of element's form elements

There are many form elements. Here is a brief sum...

Summary of the data storage structure of the nginx http module

Starting from this section, we will explain the i...

Docker uses Supervisor to manage process operations

A Docker container starts a single process when i...

Two ways to specify the character set of the html page

1. Two ways to specify the character set of the h...

UDP simple server client code example

I won’t go into details about the theory of UDP. ...

Detailed steps to install MySQL on CentOS 7

In CentOS7, when we install MySQL, MariaDB will b...

Implementation of code optimization for Vue2.x project performance optimization

Table of contents 1 Use of v-if and v-show 2. Dif...

In-depth explanation of the locking mechanism in MySQL

Preface In order to ensure the consistency and in...

Basic knowledge of HTML: a preliminary understanding of web pages

HTML is the abbreviation of Hypertext Markup Langu...