jquery - Text carousel crossfade effect? -


we're trying implement simple text carousel replaces single word in sentence few other words. fade in/out , containers width should shrink/enlarge accomodate new word. sounds simple enough we're having hard time.

should function second line on www.branch.com.

can't find plugin this? image carousel sure, not text, , not 1 changes preceding container.

it goes through words container needs change widths.

    $('#caption p:gt(0)').hide();     setinterval(function() {         $('#caption span:first-child').fadeout('slow')            .next('span').fadein('slow')            .end().appendto('#caption');     }, 2000); 

this the

 <div id="caption">       <span>best</span>       <span>ultimate</span>       <span>excellent</span>       <span>fantastic</span>    </div> 

website in town.

#container {    position: relative; }  #container p {    position: absolute;     top: 0;     left: 0; } 

any suggestions?

if want achieve more branch.com-like effect, you'll need following additions/changes":

regarding css:

#caption needs:

  • padding: 0px;
  • display: inline-block;
  • position: relative;
  • vertical-align: bottom;
  • transition: width 0.25s linear;

#caption > span needs:

  • position: absolute;
  • top: 0px;
  • left: 0px;

regarding js:
you'll need explicitely set #caption's width width of shown element (each time transition happens), using soimething this:

$("#caption").css("width", $(<the_element_to_be_shown>).width()); 

you'll have set initial width , height:

$("#caption").css("width", $("#caption > span:first-child").width()); $("#caption").css("height", $("#caption > span:first-child").height()); 

i put in short demo.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -