1.只在webkit内核的浏览器上有效果
2.语法:
-webkit-box-reflect: <direction> <offset> <mask-box-image>
direction: 倒影偏移方向,有above、below、left和right四个值;
offset: 倒影偏移原元素边框边缘的距离,单位可为px或者%;
mask-box-image: 覆盖倒影的遮罩。
3.下面是demo:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>用-webkit-box-reflect 制作倒影</title> <style> .photo-reflection{ cursor: pointer; width: 200px; height: 242px; margin: 20px auto; } /*-webkit-box-reflect: <direction> <offset> <mask-box-image>*/ .photo-reflection img{ -webkit-box-reflect:below 0 -webkit-gradient(linear, left top, left bottom, from(transparent), color-stop(0.1, transparent), to(white)); } .text-reflection{ margin-top: 240px; font-family:"Microsoft YaHei"; color: rgba(250, 82, 117, 0.93); -webkit-box-reflect: below 1px -webkit-gradient(linear, 0 0, 0 100%, from(transparent), color-stop(0, transparent), to(rgba(3,3,3,.2))); } </style> </head> <body> <div class="photo-reflection"> <img src="./qin_03.png"> <div class="text-reflection"><p>民族舞泛指产生并流传于民</p></div> </div> </body> </html>
4.效果如下: