html - Change background image opacity with css -
i want change header's background image opacity css. me please.
.intro { display: table; width: 100%; height: auto; padding: 100px 0; text-align: center; color: #fff; background: url(http://lorempixel.com/1910/500/nature/) no-repeat bottom center scroll; background-color: #000; -webkit-background-size: cover; -moz-background-size: cover; background-size: cover; -o-background-size: cover; }
<header class="intro"> ... </header>
you can change opacity in programs photoshop or gimp.
or can opacity
in css. don't want since have content in .intro
affected it.
so suggest following solution
.intro { position: relative; z-index: 0; display: table; width: 100%; height: auto; padding: 100px 0; text-align: center; color: black; background-color: transparent; -webkit-background-size: cover; -moz-background-size: cover; background-size: cover; -o-background-size: cover; } .intro:after { content : ""; display: block; position: absolute; top: 0; left: 0; background: url('http://www.planwallpaper.com/static/images/canberra_hero_image.jpg'); background-size: cover; width: 100%; height: 100%; opacity : 0.2; z-index: -1; }
https://jsfiddle.net/q63nf0la/
basically add :after
element background image , position absolute
( .intro
need position:relative;
) , set z-index
, opacity
.
Comments
Post a Comment