css3 - Is possible use fade transition on tag 'content' only with css? -


please view code jsfiddle: http://jsfiddle.net/rflfn/6wcp6/

<div id="menu">     <ul>         <li><a href="#">link #1</a></li>         <li><a href="#">link #2</a></li>         <li><a href="#">link #3</a></li>         <li><a href="#">link #4</a></li>     </ul> </div> 

css:

*{     margin: 0;     padding: 0;     text-decoration: none;     font-family: arial;     font-size: 16px; } a{     color: #000000; } a:hover{     color: #860000;     } #menu{     margin: 15px auto;     padding: 20px;     width: 300px;     background: #dddddd;      border-radius: 5px;     box-shadow: 0 0 5px #000000; } #menu ul{     list-style: none; } #menu li:before{     margin-right: 10px;     content: url("http://st.deviantart.net/emoticons/s/smile.gif");      transition: 0.5s ease 0s;     /* transition: content 0.5s ease 0s; */ } #menu li:hover:before{     content: url("http://st.deviantart.net/emoticons/r/razz.gif"); } 

i have 1 image on tag 'li' , other image on 'li:hover', possible make transition fade using css?

you can using both pseudo elements :before/after , using css3 transition animate opacity of both on hover. create fade transition between both images.

demo

css :

*{     margin: 0;     padding: 0;     text-decoration: none;     font-family: arial;     font-size: 16px; } a{     color: #000000; } a:hover{     color: #860000;     } #menu{     margin: 15px auto;     padding: 20px;     width: 300px;     background: #dddddd;      border-radius: 5px;     box-shadow: 0 0 5px #000000; } #menu ul{     list-style: none; } #menu ul li{     position:relative; } #menu li:before{     margin-right: 10px;     content: url("http://st.deviantart.net/emoticons/s/smile.gif");      transition: opacity 0.5s ease;     -webkit-transition: opacity 0.5s ease; } #menu li:after{     content: url("http://st.deviantart.net/emoticons/r/razz.gif");     position:absolute;     left:0;     opacity:0;      transition: opacity 0.5s ease;     -webkit-transition: opacity 0.5s ease; } #menu li:hover:after{     opacity:1; } #menu li:hover:before{     opacity:0; } 

edit :

even better, can position both images 1 on top of other , z-index , css transition animate opacity of ony 1 image :

demo


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -