CSS property box-reflect compatibility?

后端 未结 2 1460
庸人自扰
庸人自扰 2020-12-11 18:17

Is there similar property to -webkit-box-reflect for the mozilla and other browsers? I could not find on google which other browsers have support for this. So i

相关标签:
2条回答
  • 2020-12-11 18:55

    This is possible with not only webkit (latest chrome or safari) but also in latest firefox.

    Here is the example: http://codepen.io/jonathan/pen/pgioE

    HTML:

    <div id="someid">
       <img src="image url" />
    <div/>
    

    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%);
    }
    

    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;
     }
    

    Firefox uses -moz-element to do the reflections (https://developer.mozilla.org/en-US/docs/CSS/element), whereas webkit uses a proprietary vendor prefix for reflections.

    I hope this helps!

    0 讨论(0)
  • 2020-12-11 19:08

    The -webkit-box-reflect property is only supported by webkit browsers, namely Chrome and Safari. As it is a proprietary webkit property, there is no equivalent for other browsers.

    The alternative would be to use javascript to create a mirror element with faded opacity.

    0 讨论(0)
提交回复
热议问题