CSS animate text to image -



CSS animate text to image -

the effect i'm looking obtain user first sees hint text without arrow , text shrinks downwards 0% width , see arrow instead. container should have plenty space barely fit text within of little bit of padding. don't know if explained enough. container shrinks fit size of content , content changes text image after amount of time.

here html below.

<a href="javascript:void(0);" class="scrolldownarrow"> <div class="relative"> <div class="hint"> <p>skip next section</p> <img src="assets/img/"insert arrow img here".png" /> </div> </div> </a>

css

*{ padding:0; margin:0; } .hint { display: block; height: 38px; line-height: 34px; text-align: center; border:2px solid #f6473e; border-radius: 20px; -o-border-radius: 20px; -moz-border-radius: 20px; -wbkit-border-radius: 20px; text-transform: uppercase; color: #fff; white-space: nowrap; transition: width 0.8s ease 2.6s, margin 0.8s ease 2.6s , padding 0.8s ease 2.6s; -o-transition: width 0.8s ease 2.6s, margin 0.8s ease 2.6s, padding 0.8s ease 2.6s; -moz-transition: width 0.8s ease 2.6s, margin 0.8s ease 2.6s, padding 0.8s ease 2.6s; -webkit-transition: width 0.8s ease 2.6s, margin 0.8s ease 2.6s, padding 0.8s ease 2.6s; width:100%; overflow:hidden; position:relative; margin:0; padding: 0 20px; } .hint.show { } .hint.show p { display:inline-block; } .hint p { color:#000; width:100%; font-size: 0.8em; display:none; transition: width 0.8s ease 2.6s, opacity 0.8s ease 2s; -o-transition: width 0.8s ease 2.6s, opacity 0.8s ease 2s; -moz-transition: width 0.8s ease 2.6s, opacity 0.8s ease 2s; -webkit-transition: width 0.8s ease 2.6s, opacity 0.8s ease 2s; } .hint.show img { display:none; } .hint img { display:inline-block; width:100%; max-width:38px; transition: width 0.8s ease 2.6s, opacity 0.8s ease 2s; -o-transition: width 0.8s ease 2.6s, opacity 0.8s ease 2s; -moz-transition: width 0.8s ease 2.6s, opacity 0.8s ease 2s; -webkit-transition: width 0.8s ease 2.6s, opacity 0.8s ease 2s; position:absolute; top:-2px; transform:translatex(-50%); -o-transform:translatex(-50%); -moz-transform:translatex(-50%); -webkit-transform:translatex(-50%); } .scrolldownarrow { display: block; height: 38px; width: auto; position: absolute; bottom: 10px; left: 50%; transform:translatex(-50%); -o-transform:translatex(-50%); -moz-transform:translatex(-50%); -webkit-transform:translatex(-50%); background-size: 100%; z-index: 1000; transition: bottom 0.8s ease 1.6s, width 0.8s ease 0s; -o-transition: bottom 0.8s ease 1.6s, width 0.8s ease 0s; -moz-transition: bottom 0.8s ease 1.6s, width 0.8s ease 0s; -webkit-transition: bottom 0.8s ease 1.6s, width 0.8s ease 0s; -webkit-backface-visibility: hidden; }

js

$(document).ready(function(){ $('.scrolldownarrow').click(function(){ if ($(this).hasclass('clicked')){ $(this).removeclass('clicked'); $('.hint').removeclass('show'); }else{ $(this).addclass('clicked'); $('.hint').addclass('show'); } }); });

would ideal if hint surrounded border , whole container shrinks fit text within , text can alter in width cannot utilize fixed width.

here's fiddle made pretty close code i'm using http://jsfiddle.net/bfh55npj/3/ problem is, width isn't transitioning , instead snapping width needs.

edit: http://jsfiddle.net/bfh55npj/6/ updated fiddle reply looking in case else wants utilize it. effect doesn't work in reverse effect want needs work in 1 way, that's fine , have accounted reverse , it's there display purposes can animation 1 time again without refreshing.

i came jquery-code:

$(document).ready(function(){ $(".scrolldownarrow").click(function(){ if($(".scrolldownarrow").hasclass("clicked")){ $(".hint img").fadeout(500); $(".hint p").delay(500)/*wait on fadeout*/.animate({width: 200} /*unfortunately width: 100% not seem work took px value :(*/, 1000).animate({opacity:1}, 500); $(".scrolldownarrow").removeclass("clicked"); }else{ $(".hint p").animate({opacity:0.01}/*fade p out without making width disappear width animation*/, 500).animate({width: 0}, 1000); $(".hint img").delay(1500).fadein(500); $(".scrolldownarrow").addclass("clicked"); } }); // end click });//end ready

you can set width value @ 100% in jquery-script if want create width fit paragraph, unfortunately animation seems fail if that. ll start new question see if knows prepare that.

i removed css-animations since using jquery , using both @ 1 time kind of confusing. here jsfiddle.

css image animation text

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -