[CSS Tip] Use grayscale and blur to protect sensitive content

To protect sensitive content using blur and grayscale effects in CSS, you can apply the following styles:

Blur effect

.sensitive-content {
  filter: blur(5px); /* 设置模糊半径,根据需要调整数值 */
}

Applying .sensitive-contentthe class to an element containing sensitive content will obscure the element and its contents. If desired, you can adjust blurthe pixel value to control the degree of blur. 

Grayscale effect

.sensitive-content {
  filter: grayscale(100%); /* 将内容完全转为灰度 */
}

Applying .sensitive-contentthe class to an element containing sensitive content will cause the element and its content to be completely grayscale. You can adjust grayscalethe percentage value as needed.

Note: Blur and grayscale effects are applied to elements and their content, so they provide no real protection, just a visual blurring and graying out. For truly sensitive content protection, it is recommended to handle it on a backend server, with appropriate security measures in place.

 

Guess you like

Origin blog.csdn.net/wuzhangting/article/details/132446273