You can use the filter attribute and blur() function in HTML to blur the photo. You only need to add the "filter: blur(px);" code style to the img photo. The filter attribute is used to define the visual effect of image elements. When the value is set to "blur(value)", you can set Gaussian blur to the image.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
In HTML, you can use the filter attribute and set the value to "blur(px)" to blur the photo.
css filter attribute
##filter attribute defines the element (usually ) Visual effects (e.g. blur and saturation).
blur(px) : Set Gaussian blur to the image. The "radius" value sets the standard deviation of the Gaussian function, or how many pixels are blended together on the screen, so the larger the value, the blurr it is; if there is no set value, the default is 0; this parameter can set the css length value, but Percentage values are not accepted.
Example:<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style type="text/css"> body, html { margin: 0; padding: 0; width: 100%; height: 100%; } .container { padding: 20px; position: relative; overflow: hidden; } img { height: 200px; transition: .5s ease-in-out; } .container div { width: 300px; overflow: hidden; float: left; margin-left: 40px; } .blur img { filter: blur(15px); -webkit-filter: blur(15px); } .blur img:hover { filter: blur(0); -webkit-filter: blur(0); } </style> </head> <body> <div class="blur container"> <div> <img src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1548676269108&di=64d110c6c0c15d9bc77c7ffd4f049f1b&imgtype=0&src=http%3A%2F%2Fe.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2F6a63f6246b600c33d32b0328174c510fd8f9a184.jpg" / alt="How to make photos blurry with html code" > </div> </div> </body> </html>
##[Recommended tutorial:
CSS video tutorialFilter functionNote: Filters usually use percentages (such as: 75%), of course, they can also be expressed in decimals (such as: 0.75).
Description | |
---|---|
Default value, no effect. | |
) Set Gaussian blur to the image. The "radius" value sets the standard deviation of the Gaussian function, or how many pixels are blended together on the screen, so the larger the value, the blurr it is; | If no value is set, the default is 0; this parameter can Set css length value, but does not accept percentage value. |
)Applies a linear multiplication to the image, making it appear brighter or darker. If the value is 0%, the image will be completely black. If the value is 100%, there will be no change in the image. Other values correspond to linear multiplier effects. Values above 100% are okay and the image will be brighter than before. If no value is set, the default is 1. | |
)Adjust the contrast of the image. If the value is 0%, the image will be completely black. The value is 100% and the image is unchanged. Values can exceed 100%, meaning a lower comparison will be used. If no value is set, the default is 1. | |
) | Sets a shadow effect to the image. Shadows are composited underneath the image and can be blurred, offset versions of the matte that can be painted in a specific color. The function accepts values of type<code style="font-style: normal;line-height: 1.5"><code style="font-style: normal;line-height: 1.5"><ul><li><strong><offset-x></strong> <strong><offset-y></strong> <small>(必须)</small></li><li>这是设置阴影偏移量的两个 <length>值. <strong><offset-x></strong> 设定水平方向距离. 负值会使阴影出现在元素左边. <strong><offset-y></strong>设定垂直距离.负值会使阴影出现在元素上方。查看<strong><length></strong>可能的单位.<br/> <strong><span style="font-family:Open Sans, sans-serif">如果两个值都是</span>0</strong>, 则阴影出现在元素正后面 (如果设置了<span style="line-height: 1.5"> </span><code style="font-style: normal;line-height: 1.5"><blur-radius><span style="line-height: 1.5"> and/or </span><code style="font-style: normal;line-height: 1.5"><spread-radius>,<span style="line-height: 1.5">会有模糊效果</span><span style="line-height: 1.5">).</span><code style="font-style: normal;line-height: 1.5"><code style="font-style: normal;line-height: 1.5"> 注意: Webkit, 以及一些其他浏览器 不支持第四个长度,如果加了也不会渲染。 |
grayscale(%) | 将图像转换为灰度图像。值定义转换的比例。值为100%则完全转为灰度图像,值为0%图像无变化。值在0%到100%之间,则是效果的线性乘子。若未设置,值默认是0; |
hue-rotate(deg) | 给图像应用色相旋转。"angle"一值设定图像会被调整的色环角度值。值为0deg,则图像无变化。若值未设置,默认值是0deg。该值虽然没有最大值,超过360deg的值相当于又绕一圈。 |
invert(%) | 反转输入图像。值定义转换的比例。100%的价值是完全反转。值为0%则图像无变化。值在0%和100%之间,则是效果的线性乘子。 若值未设置,值默认是0。 |
opacity(%) | 转化图像的透明程度。值定义转换的比例。值为0%则是完全透明,值为100%则图像无变化。值在0%和100%之间,则是效果的线性乘子,也相当于图像样本乘以数量。 若值未设置,值默认是1。该函数与已有的opacity属性很相似,不同之处在于通过filter,一些浏览器为了提升性能会提供硬件加速。 |
saturate(%) | 转换图像饱和度。值定义转换的比例。值为0%则是完全不饱和,值为100%则图像无变化。其他值,则是效果的线性乘子。超过100%的值是允许的,则有更高的饱和度。 若值未设置,值默认是1。 |
sepia(%) | 将图像转换为深褐色。值定义转换的比例。值为100%则完全是深褐色的,值为0%图像无变化。值在0%到100%之间,则是效果的线性乘子。若未设置,值默认是0; |
url() | URL函数接受一个XML文件,该文件设置了 一个SVG滤镜,且可以包含一个锚点来指定一个具体的滤镜元素。 例如: filter: url(svg-url#element-id) Copy after login 更多编程相关知识,请访问:编程视频!! The above is the detailed content of How to make photos blurry with html code. For more information, please follow other related articles on the PHP Chinese website!
Previous article:How to change the font of tags in html
Next article:How to set text spacing in html
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
Latest Articles by Author
Latest Issues
PX automatic conversion to REM error
<style>html { font-size: calc(100vw / 3.75); }...
From 2024-04-16 09:34:16
0
0
4687
Related Topics
More>
|