html代碼很簡單
1 、半透明效果可以使用 css3 中的 opacity 屬性,在低版本的IE浏覽器中使用IE的alpha 濾鏡。代碼:
.opacity{ opacity:0.3; filter: alpha(opacity=30); background-color:#000; }
2 、要覆寫整個可視區域通常的做法是:
html,body{ height:100%}
.mask{height:100%;width:100%;}
但是這樣做當内容超過一屏時隻有IE6下顯示的效果是我們所期望的,在其他浏覽器中首屏以下的沒能被遮蓋住,為了相容其他浏覽器我們可以使用position:fixed; 來解決這個問題
完整的代碼:
html,body{ height:100%; margin:0; padding:0}
.mask{height:100%; width:100%; position:fixed; _position:absolute; top:0; z-index:1000; }
.opacity{ opacity:0.3; filter: alpha(opacity=30); background-color:#000; }
一個實際的代碼例子:
複制代碼代碼如下:
背景半透明覆寫整個可視區域
html,body{ height:100%; margin:0; padding:0; font-size:14px;}
p{ line-height:18px;}
.mask{height:100%; width:100%; position:fixed; _position:absolute; top:0; z-index:1000; }
.opacity{ opacity:0.3; filter: alpha(opacity=30); background-color:#000; }
.content{height:600px; width:800px; overflow:auto; border:2px solid #ccc; background-color:#fff; position:absolute; top:50%; left:50%; margin:-300px auto auto -400px; z-index:1001; word-wrap: break-word; padding:3px;}
.ph{ height:1000px;}
place holder height:1000px;
背景半透明覆寫整個可視區域
這個效果效果在工作中經常會遇到,這篇文章主要介紹了當内容超過一屏時如何做到多浏覽器的相容性。 下面我們通過一個簡單的例子看看如何實作,高手請繞道。
html代碼很簡單 < d i v class="mask opacity">< / d i v >
1 、半透明效果可以使用 css3 中的 opacity 屬性,在低版本的IE浏覽器中使用IE的alpha 濾鏡。代碼:
.opacity{ opacity:0.3; filter: alpha(opacity=30); background-color:#000; }
2 、要覆寫整個可視區域通常的做法是:
html,body{ height:100%}
.mask{height:100%;width:100%;}
但是這樣做當内容超過一屏時隻有IE6下顯示的效果是我們所期望的,在其他浏覽器中首屏以下的沒能被遮蓋住,為了相容其他浏覽器我們可以使用
position:fixed;
來解決這個問題
完整的代碼:
html,body{ height:100%; margin:0; padding:0}
.mask{height:100%; width:100%; position:fixed; _position:absolute; top:0; z-index:1000; }
.opacity{ opacity:0.3; filter: alpha(opacity=30); background-color:#000; }