Home >Web Front-end >HTML Tutorial >How to set transparency to background image in html
htmlHow to set the transparency of the background image: 1. Use the opacity attribute to add the "opacity: transparency value;" style to the element that sets the background image; 2. Use the filter attribute to set the background image. Just add the "filter: opacity (transparency value);" style to the element.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
htmlSet the transparency of the background image
1. Use the opacity attribute
<!DOCTYPE html> <html> <head> <style type="text/css"> div { width: 300px; height: 300px; background-image: url(img/3.jpg); } .box{ opacity: 0.5; } </style> </head> <body> <div>背景图片</div> <div class="box">背景图片</div> </body> </html>
2. Use the filter attribute
<!DOCTYPE html> <html> <head> <style type="text/css"> div { width: 300px; height: 300px; background-image: url(img/3.jpg); } .box{ filter: opacity(0.6); } </style> </head> <body> <div>背景图片</div> <div class="box">背景图片</div> </body> </html>##Related recommendations: "
html video tutorial 》
The above is the detailed content of How to set transparency to background image in html. For more information, please follow other related articles on the PHP Chinese website!