html - transition between background color and background image CSS3 -


i've got set of divs , want each of them have different background color , while on hover transition background image of chosen url. have far managed find code smooth color -> image transition requires actual img code in html , need divs putting text in them.

is there chance have smooth 0.5s or less transition background color background url performed through css?

if @ http://loopedmag.com can see want recreate in code transitioned animation color->image.

you can't animate background property solid color image css3 transitions.

to achieve desired behaviour, need fade in/out layer solid background color. may use pseudo element minimize markup layer.

demo

html :

<div class="one"></div> <div class="two"></div> 

css :

body,html{     height:100%; }  div{     height:50%;     width:50%;     position:relative;     background-size:cover; } .one{     background: url(http://lorempixel.com/output/fashion-q-c-640-480-3.jpg); } .two{     background: url(http://lorempixel.com/output/people-q-g-640-480-7.jpg); } div:after{     content:'';     position:absolute;     left:0; top:0;     width:100%;     height:100%;     background:gold;     opacity:1;      -webkit-transition: opacity .5s;     transition: opacity .5s; } div:hover:after{     opacity:0; } 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -