Pure CSS to achieve horizontal line animation under the element (background-image)

Pure CSS to achieve horizontal line animation under the element (background-image)

Effect picture:

html:

<div class='site_bar'>Home</div>
css:
.site_bar{
  background-image : linear-gradient(red,red);
  background-position : center bottom;
  background-size : 0 2px;
  background-repeat : no-repeat; //This attribute cannot be missing.
  transition : .3s;
}
.site_bar:hover{
  background-size : 100% 2px;
}

Summarize

The above is the pure CSS implementation of horizontal line animation (background-image) under the element introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

<<:  Some questions about hyperlinks

>>:  JavaScript imitates Jingdong magnifying glass effect

Recommend

JS+Canvas realizes dynamic clock effect

A dynamic clock demo based on Canvas is provided ...

Detailed explanation of JS variable storage deep copy and shallow copy

Table of contents Variable type and storage space...

Implementation of Docker deployment of web projects

The previous article has installed the docker ser...

Causes and solutions to the garbled character set problem in MySQL database

Preface Sometimes when we view database data, we ...

Example code for implementing a simple search engine with MySQL

Table of contents Preface Introduction ngram full...

How to implement remote connection for Redis under Linux

After installing Redis on Linux, use Java to conn...

Detailed explanation of the use of docker tag and docker push

Docker tag detailed explanation The use of the do...

Illustration-style website homepage design New trend in website design

You can see that their visual effects are very bea...

Analysis of MySQL's method of exporting to Excel

This article describes how to use MySQL to export...

Tutorial diagram of installing CentOS and Qt in Vmware virtual machine

Vmware Installation Installing Packages Download ...

Solve the problem of spring boot + jar packaging deployment tomcat 404 error

1. Spring boot does not support jsp jar package, ...

JavaScript - Using slots in Vue: slot

Table of contents Using slots in Vue: slot Scoped...