我想模糊div的內容,而這個功能在谷歌瀏覽器,但不是在mozila Firefox中正常工作,jQuery函數在mozila Firefox中不工作,但在谷歌瀏覽器的工作
這是我的代碼,
<!doctype html>
<html>
<head>
<title>How to create blur effect with jQuery and CSS</title>
<style>
body{
text-align: center;
}
input{
margin-top:20px;
font-size:16px;
font-weight: bold;
padding:5px 10px;
}
#box{
margin:50px auto;
width:500px;
height:100px;
color:#fff;
padding:10px;
background: #333;
}
</style>
</head>
<body>
<input type="button" value="Blur Box" class="button" />
<input type="button" value="Reset Box" class="button2" />
<div id="box">We use Google's CDN to serve the jQuery js libs.
To speed up the page load we put these scripts at the bottom of the page </div>
<!--
We use Google's CDN to serve the jQuery js libs.
To speed up the page load we put these scripts at the bottom of the page
-->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
//DOM loaded
$(document).ready(function() {
//attach click event to button
$('.button').click(function(){
//when button is clicked we call blurElement function
blurElement("#box", 2);
});
//attach click event to button
$('.button2').click(function(){
//set box blur to 0
blurElement("#box", 0);
});
});
//set the css3 blur to an element
function blurElement(element, size){
var filterVal = 'blur('+size+'px)';
$(element)
.css('filter',filterVal)
.css('webkitFilter',filterVal)
.css('mozFilter',filterVal)
.css('oFilter',filterVal)
.css('msFilter',filterVal);
}
</script>
</body>
</html>
請幫助我,如何在所有瀏覽器(特別是mozilla firefox,IE 9+)中運行此代碼 在此先感謝。
你看着http://stackoverflow.com/questions/8514954/blur-imgs-divs-in-html-using-css?其中一個答案中的一條評論鏈接到http://caniuse.com/#feat=css-filters,其中顯示了當前瀏覽器對CSS過濾器的支持 – Sean 2014-10-12 03:36:28
請參閱http://caniuse.com/#feat=css-filters – 2014-10-12 03:38:20