The effect is as follows: HTML: <div class="itemInWorks" > Wedding Planning Status: To be completed<br> Executor: Zhang San<br> Deadline: 2020/03/15 </div> </div> CSS: /*Outer div part*/ .itemInWorks{ width: 180px; height: 130px; border-radius:5px;/*rounded corners*/ font-size: 18px; font-weight: 600; color: dimgrey; text-align: center;/*The text "Wedding Planning" is horizontally centered*/ line-height: 50px;/*The text "Wedding Planning" is vertically centered*/ background: url('image/works_image/4.jpg'); background-repeat: no-repeat; background-size: 180px 130px; box-shadow: #909090 0px 0px 10px;/*surrounding shadow*/ /*The above is customized according to personal effect*/ overflow: hidden; position: relative; } /*semi-transparent part*/ .itemInWorks .mask{ height:80px; width:172px; color: #f5f1e5; line-height: 23px; text-align: left; padding-left: 8px; border-radius:2px 2px 5px 5px; font-size: 14px; font-weight: 300; /*The above is customized according to personal effect*/ position: absolute; top:130px;/*When the mouse is not released, the distance between the highest point of the semi-transparent part and the top of the outer div*/ background-color:rgba(0,0,0,0.5);/*transparency*/ transition:top 0.5s ease-in-out;/*Change the top property, complete in 0.5 seconds, start slowly and end slowly*/ } .itemInWorks:hover .mask{ top:50px ;/*When the mouse is placed on the top, the distance from the top of the outer div to the highest point of the slide*/ } Full code: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <style> .itemInWorks{ width: 180px; height: 130px; border-radius:5px; font-size: 18px; font-weight: 600; color: dimgrey; text-align: center; line-height: 50px; background: url('image/works_image/4.jpg'); background-repeat: no-repeat; background-size: 180px 130px; box-shadow: #909090 0px 0px 10px; overflow: hidden; position: relative; } /*semi-transparent part*/ .itemInWorks .mask{ height:80px; width:172px; color: #f5f1e5; line-height: 23px; text-align: left; padding-left: 8px; border-radius:2px 2px 5px 5px; font-size: 14px; font-weight: 300; position: absolute; top:130px; background-color:rgba(0,0,0,0.5); transition:top 0.5s ease-in-out; } .itemInWorks:hover .mask{ top:50px ; } </style> <body> <div class="itemInWorks" > Wedding Planning Status: To be completed<br> Executor: Zhang San<br> Deadline: 2020/03/15 </div> </div> </body> </html> Summarize The above is the editor's introduction to the pure CSS text description of how to achieve a translucent effect when the mouse is placed on the screen (a must-read for novices). I hope it will be helpful to everyone! |
<<: How to quickly build an LNMP environment with Docker (latest)
Install Required Files Yum install openssl-* -y C...
Table of contents 1. Swap partition SWAP 1.1 Crea...
Recently, in order to realize the course design, ...
In daily work, we sometimes run slow queries to r...
Table of contents 1. Shopping cart example 2. Cod...
Table of contents 1. Project Prospects 2. Knowled...
1. Introduction As we all know, in the applicatio...
Front-end is a tough job, not only because techno...
This article uses an example to describe the crea...
Table of contents View network configuration View...
1. MYSQL index Index: A data structure that helps...
There are four types of positioning in CSS, which...
Contents of this article: Page hollow mask layer,...
1. First, you need to know what will trigger the v...
A static node is fixed on a machine and is starte...