首先效果如下:
阴影效果完整代码如下
上面的动态图是没有加transition的,为了美观加上了一个
<!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> .text_str_obj{ width: 200px; height: 100px; border-radius: 20px; background-color: #ffffff; box-shadow: 0px 6px 12px 0px rgba(0, 0, 0, 0.5); transition: box-shadow 0.3s ease-in-out; } .text_str_obj p{ line-height: 90px; text-align: center; } .text_str_obj:hover{ box-shadow: 0px 10px 22px 0px rgba(0, 0, 0, 0.5); } </style> </head> <body> <div class="text_str_obj"> <p>素材</p> </div> </body> </html>