国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > CSS > 正文

CSS圖片倒影效果兼容firefox、IE等各主流瀏覽器

2024-07-11 08:29:12
字體:
來源:轉載
供稿:網友
無需flash,完全用css就可以做出超炫的圖片倒影效果。網上流傳很多種版本,經過本人的一番研究,做成能夠兼容firefox、chrome、IE等各主流瀏覽器的版本,跟大家分享一下。最終完成的效果

新瀏覽器的實現
指的是firefox、chrome和IE9。新瀏覽器都支持CSS3新添的transform屬性,所以實現倒影效果非常簡單。從下面的代碼看到,各家瀏覽器對transform的實現有點不同
-webkit-transform: scaleY(-1); /* webkit內核瀏覽器的實現,例如safari */
-moz-transform: scaleY(-1); /* firefox 的實現 */
-ms-transform: scaleY(-1); /* IE 的實現 */
-o-transform: scaleY(-1); /* Opera的實現 */
HTML

復制代碼
代碼如下:
<div class="wrap">
<div class="image"><img src="1.jpg" /></div>
<div class="down">
<div class="reflection"></div>
<div class="overlay"></div>
</div>
</div>

CSS

復制代碼
代碼如下:
body{background:#000;color:#f00}
.wrap{position:relative;}
.image{margin-bottom:3px;}
.down{position: relative;}
.reflection{width:421px;height:180px;background:url(1.jpg) bottom center no-repeat;
-webkit-transform: scaleY(-1);
-moz-transform: scaleY(-1);
-ms-transform: scaleY(-1);
-o-transform: scaleY(-1);
transform: scaleY(-1);
opacity:0.5;
filter:alpha(opacity='50');
}
.overlay{position: relative;width:421px;height:180px;bottom:149px;
background-image: -moz-linear-gradient(center bottom, rgb(0,0,0) 20%, rgba(0,0,0,0) 90%);
background-image: -o-linear-gradient(rgba(0,0,0,0) 10%, rgb(0,0,0) 30%);
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0.20, rgb(0,0,0)), color-stop(0.90, rgba(0,0,0,0)));
filter: progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColor=0, EndColorStr=#000000);
}

在倒轉的圖片上面還加了一個DIV.overlay層,做出漸變的效果,使倒影看起來更真實。
兼容舊瀏覽器的實現
考慮到還有相當多的人在使用舊版瀏覽器,程序員絞盡腦汁為這部分人做兼容。這里指的是IE7/IE8。IE6怎么辦?提示用戶升級瀏覽器吧。
舊IE不支持transform屬性,可以使用濾鏡 filter:flipv 來生成圖片倒轉,但會跟IE9的transform沖突。所以要用到各種 hack 來解決。修改后的CSS如下,添加了IE9 hack,覆蓋掉上面的filter:flipv的屬性。

復制代碼
代碼如下:
body{background:#000;color:#f00}
.wrap{position:relative;}
.image{margin-bottom:3px;}
.down{position: relative;}
.reflection{width:421px;height:180px;background:url(1.jpg) bottom center no-repeat;
-webkit-transform: scaleY(-1);
-moz-transform: scaleY(-1);
-ms-transform: scaleY(-1);
-o-transform: scaleY(-1);
transform: scaleY(-1);
opacity:0.5;
filter:flipv alpha(opacity='50'); /*ALL IE*/
}
@media all and (min-width:0) {
.reflection{filter:alpha(opacity='50') /0/;} /*IE9*/
}
.overlay{position: relative;width:421px;height:180px;bottom:149px;
background-image: -moz-linear-gradient(center bottom, rgb(0,0,0) 20%, rgba(0,0,0,0) 90%);
background-image: -o-linear-gradient(rgba(0,0,0,0) 10%, rgb(0,0,0) 30%);
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0.20, rgb(0,0,0)), color-stop(0.90, rgba(0,0,0,0)));
filter: progid:DXImageTransform.Microsoft.Gradient(gradientType=0,startColor=0, EndColorStr=#000000);
}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 沅陵县| 舒城县| 乐平市| 阿巴嘎旗| 开化县| 呼图壁县| 临颍县| 章丘市| 元氏县| 太和县| 长葛市| 株洲市| 台江县| 浦北县| 临沭县| 林州市| 文登市| 南汇区| 永济市| 永济市| 广水市| 突泉县| 林周县| 乌兰浩特市| 岗巴县| 昌黎县| 建始县| 历史| 桓台县| 潢川县| 房产| 都匀市| 荣昌县| 桂平市| 汝阳县| 周口市| 夏河县| 乐陵市| 凯里市| 恭城| 日照市|