Home > Article > Web Front-end > How Can I Recreating iOS 7\'s Blurred Overlay Effect with CSS?
iOS 7's Blurred Overlay Effect Recreated with CSS
Apple's overlay effect in iOS 7 is not simply a matter of transparency, but involves a subtle blur that adds depth and interest. This article explores how to replicate this effect using CSS, revealing the secrets behind the blurred overlay.
CSS Blur Filter
The key to achieving this blurred effect lies in the CSS blur() filter, which is available in modernen browsers such as Chrome, Firefox, Safari, and IE10 . The syntax for using the blur() filter is straightforward:
<code class="css">filter: blur(value);</code>
where value represents the desired blur radius in pixels. For a subtle blur similar to Apple's overlay, a value of around 20 pixels is recommended.
Example Implementation
To apply the blurred effect to an element on your page, simply add the following CSS rule:
<code class="css">#myDiv { -webkit-filter: blur(20px); -moz-filter: blur(20px); -o-filter: blur(20px); -ms-filter: blur(20px); filter: blur(20px); opacity: 0.4; }</code>
Note that you may need to include vendor prefixes for compatibility with older browsers. Also, don't forget to specify an opacity value to ensure that the blurred overlay does not completely obscure the underlying content.
Example in JavaScript
If you prefer to apply the blur effect dynamically using JavaScript, you can use the following code:
<code class="javascript">var element = document.getElementById('myDiv'); element.style.filter = 'blur(20px)'; element.style.opacity = 0.4;</code>
By utilizing the blur() filter and optionally combining it with JavaScript, you can easily recreate the blurred overlay effect used in iOS 7, enhancing the visual aesthetics of your web applications.
The above is the detailed content of How Can I Recreating iOS 7\'s Blurred Overlay Effect with CSS?. For more information, please follow other related articles on the PHP Chinese website!