Home > Article > Web Front-end > Through CSS3, achieve element coverage effect_html/css_WEB-ITnose
In many websites, we can see this effect. When the user enters an element with the mouse, there will be a floating mask layer animation below, as shown in the picture:
Today we will use hover pseudo-class plus css3 to implement without using any JS
<!DOCTYPE html><html><head lang="zh-cmn-Hans"> <meta charset="UTF-8"> <title></title> <style> #d1{ height: 100px; position: relative; width: 100px; overflow: hidden; } #d1:hover > #d3{ transition: transform 0.5s ease; transform: translateY(-100%); } #d2{ background: red; height: 100px; width: 100px; } #d3{ color: white; background: #111; height: 100px; opacity: 0.6; width: 100px; } </style></head><body> <div id="d1"> <div id="d2"></div> <div id="d3"></div> </div></body></html>