Home > Web Front-end > uni-app > body text

Use uniapp to achieve picture blur effect

WBOY
Release: 2023-11-21 13:30:43
Original
1845 people have browsed it

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.

  1. Introduce pictures
    First, add a file in the static directory of the uniapp project or the static directory of uniapp A picture that needs to be blurred, for example named blur.jpg.
  2. Display pictures on the page
    Add the following code in the 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>
Copy after login
  1. 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>
    Copy after login

    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.

    1. Run and preview the effect
      Run the project through the uniapp development tool, and then you can see the image with the blur effect added on the page.

    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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!