In most of the websites we will see reflection graphics on images like below. But most of the web developers and web designers are using images (Photoshop images) to achieve the below effect.
Photoshop reflection (Using Photoshop)
But now using CSS3 we can achieve the above reflection effect easily without using tools like Photoshop.
CSS3 reflection (DEMO)
Use the below code to achieve the same.
Use the below CSS code.
- <style>
- .product
- {
- float:left;
- width:150px;
-
- }
- .product img
- {
- width:100px;
- }
- .shadow {
- width:100%;
- height:100%;
- position:absolute; top:0px; left:0px; ;
- background-image: -moz-linear-gradient( center bottom, rgb(255,255,255) 60%, rgba(255,255,255,0) 75%);
- background-image: -o-linear-gradient( rgba(255,255,255,0) 25%, rgb(255,255,255) 40%);
- background-image: -webkit-gradient( linear, left bottom, left top, color-stop(0.60, rgb(255,255,255)), color-stop(0.75, rgba(255,255,255,0)));
- filter: progid:DXImageTransform.Microsoft.Gradient( gradientType=0, startColor=0, EndColorStr=#ffffff);
- }
- .reflection
- {
- position:relative;
- height:200px;
- overflow:hidden;
- }
-
- .reflection img
- {
- -webkit-transform: scaleY(-1);
- opacity:0.1;
-
- }
- </style>
Use the below HTML code.
- <div class="product">
-
- <img src="m1.jpg">
-
- <div class="reflection">
-
- <img src="m1.jpg">
-
- <div class="shadow"></div>
-
- </div>
-
- </div>
-
- <div class="product">
-
- <img src="m2.jpg">
-
- <div class="reflection">
-
- <img src="m2.jpg">
-
- <div class="shadow"></div>
-
- </div>
-
- </div>
-
- <div class="product">
-
- <img src="m3.jpg">
-
- <div class="reflection">
-
- <img src="m3.jpg">
-
- <div class="shadow"></div>
-
- </div>
-
- </div>
