Home > Article > Web Front-end > Use uniapp to achieve picture blur effect
Use uniapp to achieve picture blur effects
With the development of mobile applications, more and more applications need to add picture blur effects to improve user experience. In the uniapp development framework, we can achieve the image blur effect through some simple codes.
static
directory of the uniapp project or the static
directory of uniapp
A picture that needs to be blurred, for example named blur.jpg
. template
tag of the page where the picture needs to be displayed: <template> <view class="container"> <image src="../../static/blur.jpg" class="blur-img"></image> </view> </template>
Add CSS style
Add the following CSS style in the style
tag of the same page or in the public style file:
<style> .container { display: flex; justify-content: center; align-items: center; height: 100vh; } .blur-img { width: 300px; height: 300px; filter: blur(5px); } </style>
In the above code, style.blur-img
is the key, by setting its filter: blur(5px)
to achieve the blur effect of the image. 5px
is the degree of blur, you can adjust it as needed.
Summary:
Through the above code examples, we can see that it is very simple to achieve the image blur effect under the uniapp development framework. Use the filter: blur(5px)
attribute to easily achieve the blur effect of the image. We can adjust the degree of blur according to our own needs to achieve the desired effect. I hope this article will help you understand and use uniapp to achieve image blur effects.
The above is the detailed content of Use uniapp to achieve picture blur effect. For more information, please follow other related articles on the PHP Chinese website!