是否有与-webkit-box-reflect
mozilla和其他浏览器类似的属性?我在google上找不到其他浏览器支持的内容.因此,如果有人可以告诉我或给我链接,那将是非常好的.
Jon*_*llo 10
这不仅可以使用webkit(最新的chrome或safari),还可以使用最新的firefox.
这是一个例子:http://codepen.io/jonathan/pen/pgioE
HTML:
<div id="someid">
<img src="image url" />
<div/>
Run Code Online (Sandbox Code Playgroud)
CSS(webkit):
#someid {
/* need some space for the reflection */
margin-bottom: 120px;
/* the gradient makes the reflection fade out */
-webkit-box-reflect: below 0px -webkit-linear-gradient(bottom, rgba(255,255,255,0.3) 0%, transparent 40%, transparent 100%);
}
Run Code Online (Sandbox Code Playgroud)
CSS(Firefox - Gecko):
#someid {
position: relative;
/* need some space for the reflection */
margin-bottom: 120px;
}
#someid:before {
content:""; /* needed or nothing will be shown */
background: -moz-linear-gradient(top, white, white 30%, rgba(255,255,255,0.9) 65%, rgba(255,255,255,0.7)) 0px 0px, -moz-element(#someid) 0px -127px no-repeat;
-moz-transform: scaleY(-1); /* flip the image vertically */
position:relative;
height:140px;
width: 360px; /* should be > image width + margin + shadow */
top: 247px;
left:0px;
}
Run Code Online (Sandbox Code Playgroud)
Firefox用于-moz-element
做反射(https://developer.mozilla.org/en-US/docs/CSS/element),而webkit使用专有的供应商前缀进行反射.
我希望这有帮助!
该-webkit-box-reflect
属性仅受webkit浏览器支持,即Chrome和Safari.由于它是一个专有的webkit属性,因此没有其他浏览器的等价物.
另一种方法是使用javascript创建一个具有褪色不透明度的镜像元素.