This article mainly introduces the CSS to achieve transparent background image and text opacity effect of two methods, the need for friends can refer to the next
Summary:
Method One (frosted glass effect): Background image + Pseudo class + Flite:blur (3px)
Method Two (translucent effect): Background map + positioning + Background:rgba (255,255,255,0.3)
CSS to achieve a transparent background picture, text opacity effect of two ways
Projects are often used to put some text on the background map, the introduction of two techniques to achieve a transparent background image, text opaque effect, record, easy to learn later.
1. Frosted Glass Effect:
Background map + pseudo class + Flite:blur (3px)
. demo1{ width:500px; height:300px; line-height:50px; Text-align:center;}. demo1:before{ Background:url (http://csssecrets.io/images/tiger.jpg) no-repeat; Background-size:cover; width:500px; height:300px; Content: ""; Position:absolute; top:0; left:0; Z-index: -1;/*-1 can be background * /-webkit-filter:blur (3px); Filter:blur (3px);}
<p class= "Demo1" > Background map Translucent, text opaque <br/> Method: Background map + filter:blur</p>
2. Translucent Effect:
Background map + positioning + Background:rgba (255,255,255,0.3)
. demo2-bg{ Background:url (http://csssecrets.io/images/tiger.jpg) no-repeat; Background-size:cover; width:500px; height:300px; Position:relative;}. demo2{ Position:absolute; left:0; right:0; top:0; bottom:0; width:500px; height:300px; line-height:50px; Text-align:center; Background:rgba (255,255,255,0.3);} <p class= "DEMO2-BG" > <p class= "Demo2" > Background translucent, text opaque <br/> Method: Positioning + Background:rgba ( 255,255,255,0.3) </p></p>