10
我有背景圖片,想要模糊它的特定部分而不影響整個圖像?例如,只有左下角,中間或右上角?是否有可能這樣做?是否可以使用CSS濾鏡僅模糊圖像的特定部分?
我有背景圖片,想要模糊它的特定部分而不影響整個圖像?例如,只有左下角,中間或右上角?是否有可能這樣做?是否可以使用CSS濾鏡僅模糊圖像的特定部分?
不幸的是,僅使用CSS
就無法做到這一點。您可以通過在包含背景圖像的相同容器中添加額外的absolute
元素來實現目標。
可能是這樣的。
$(document).ready(function() {
$('button').click(function(e) {
$(".blurry").css('background-color', 'white')
.css('opacity', '.1')
.css('box-shadow', 'white 0px 0px 20px 20px');
});
});
.wrapper {
width:500px;
height:150px;
position:relative;
}
#brand {
width:500px;
height:150px;
display:inline-block;
background-image:url("http://spmdesign.net/wp-content/uploads/2013/05/ss-2-bg.jpg");
}
.blurry {
width:40px;
height:50px;
position:absolute;
left:30px;
bottom:25px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
<div class="wrapper">
<a id="brand"></a>
<div class="blurry"></div>
</div>
</div>
<button>blur</button>
什麼是您的實際目標是什麼?您是否試圖隱藏信息(因爲客戶端模糊不會幫助解決這些問題)或者只是幫助用戶專注於圖像的一部分? – merlin2011
檢查這些:https://css-tricks.com/frosting-glass-css-filters/ && http://jordanhollinger.com/2014/01/29/css-gaussian-blur-behind-a-translucent-box/&& https://css-tricks.com/almanac/properties/f/filter/ && https://css-tricks.com/blurry-background-effect/ – henser
@henser非常感謝 – alpha