First, let me show you the finished effect Main idea: In fact, this blinds still uses a kind of sleight of hand. It seems that the picture expands after we move the mouse over it. In fact, these pictures do not move at all. We just put these pictures in a list, superimpose them on each other, and change the width of the list when the mouse moves. Step One: Build a Shutter Frame HTML code: <div class="container"> <ul> <li></li> <li></li> <li></li> <li></li> <li></li> </ul> </div> CSS code: *{ margin: 0; padding: 0; } .container{ margin: 100px auto; border: 2px solid #568bc7; width: 800px; height: 300px; } .container ul{ display: flex; } .container li{ width: 160px; height: 300px; list-style: none; border-left: 1px solid #194b8d; } .container li img{ display: block; width: 800px; height: 300px; } Note: The width of the li here may need to be calculated manually. Although the elastic box can be used to achieve automatic equal division, I found a bug after adding hover. You can try it. The elastic box is not used here. Now the following framework is obtained: Step 2: Insert the picture and use hover to create special effects I inserted five paintings here Here we can find that the image exceeds the scope of our container At this point we add an overflow hidden Such a blind is of scale. How to make the picture move like the demonstration GIF? .container ul:hover li{ width: 40px; } .container ul li:hover{ width: 600px; } This demo is actually an exercise in the flexible use of the :hover attribute. Step 3: Details After completing the above, we can see that the whole process is very stiff. Here we can add transition attributes to make the change smoother. At the same time, add a little shadow effect to the left border of each li to make it look more three-dimensional. box-shadow: 0 0 25px #000; transition: all 0.5s; Finally it's done Here is the full code: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> *{ margin: 0; padding: 0; } .container{ margin: 100px auto; border: 2px solid #568bc7; width: 800px; height: 300px; overflow: hidden; } .container ul{ display: flex; } .container li{ width: 160px; height: 300px; list-style: none; border-left: 1px solid #194b8d; box-shadow: 0 0 25px #000; transition: all 0.5s; } .container li img{ display: block; width: 800px; height: 300px; } .container ul:hover li{ width: 40px; } .container ul li:hover{ width: 600px; } </style> </head> <body> <div class="container"> <ul> <li><img src="./img/tq1.jpg" alt=""></li> <li><img src="./img/tq2.jpg" alt=""></li> <li><img src="./img/tq3.jpg" alt=""></li> <li><img src="./img/tq4.jpg" alt=""></li> <li><img src="./img/tq5.jpg" alt=""></li> </ul> </div> </body> </html> This is the end of this article about how to achieve image blinds display effect with pure CSS. For more relevant CSS image blinds content, please search 123WORDPRESS.COM’s previous articles or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! |
<<: What is the function of !-- -- in HTML page style?
>>: Detailed explanation of JavaScript BOM composition and common events
In the article MySQL Optimization: Cache Optimiza...
Table of contents 1. How to obtain elements Get i...
Table of contents 1.1. Network access between con...
Two small problems, but they bothered me for a lon...
Table of contents 1. Achieve results 2. Backend i...
Table of contents Overview Functionality and read...
I accidentally discovered a great artificial inte...
Sometimes we may need to run some commands on a r...
Primitive values -> primitive types Number S...
No way, no way, it turns out that there are peopl...
1. Command Introduction The file command is used ...
Operating system: Ubuntu 17.04 64-bit MySQL versi...
1. Brief Introduction Vue.js allows you to define...
Linux has been loved by more and more users. Why ...
Table of contents Pitfalls encountered in timesta...