css实现自适应悬浮颜色卡片效果代码
代码语言:html
所属分类:悬停
代码描述:css实现自适应悬浮颜色卡片效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> @import url('https://fonts.googleapis.com/css2?family=Martel+Sans:wght@200;600&display=swap'); main { width: 100vw; display: flex; flex-wrap: wrap; justify-content: space-around; align-items: center; } .wrap { width: 300px; height: 250px; margin: 1.5rem .5rem; display: flex; flex-direction: column; border-radius: 1rem; box-shadow: 5px 5px 30px -10px rgba(0, 0, 255, 1); overflow: hidden; } .overlay { display: flex; justify-content: center; align-items: center; position: relative; width: 100%; height: 100%; } .overlay p { font-size: 30pt; font-weight: 600; transition: .4s ease-in-out; } .wrap:hover .overlay p { transform: translateX(-60px); } .shades { position: absolute; top: 0; right: 0; width: 120px; height: 100%; transform: translateX(120px); transition: .4s ease-in-out; } .wrap:hover .shades { transform: translateX(0); } .shade { display: grid; place-items: center; height: 33.333%; font-size: 11pt; text-align: center; opacity: 0; transform: translateX(120px); transition: .3s ease-in-out; } .shade:nth-child(1) { border-radius: 0 1rem 0 0; } .wrap:hover .shade { opacity: 1; transform: translateX(0); } .wrap:hover .shade:nth-child(1) { transition-delay: .2s; } .wrap:hover .shade:nth-child(2) { transition-delay: .4s; } .wrap:hover .shade:nth-child(3) { transition-delay: .6s; } .info { width: 100%; padding: .25rem 1rem; background: white; } .info p { font-size: 11pt; } .red { color: red; } .green { color: green; } .blue { color: blue; } body { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(to bottom right, deepskyblue, dodgerblue, deepskyblue); font-family: 'Martel Sans', sans-serif; color: #fff; line-height: 1.3; } * { padding: 0; margin: 0; box-sizing: border-box; } </style> </head> <body > <main> <div class="wrap"> <div class="overlay&.........完整代码请登录后点击上方下载按钮下载查看
网友评论0