April 29, 2011

Fade Out Text Effect with jQuery

Text Fade Out is an idea of CSS-Tricks that uses jQuery to create a text-blurs, cutting at a certain height and adding a button to expand.
Obviously, you must have added the jQuery library before </ head> :

<script src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js' type='text/javascript'/>

And then the script with the effect is very short :

<script type='text/javascript'>
//<![ CDATA [
$ (Function () {
var $ a, $ ps, $ up, totalHeight;
$ (" . textfadeout-demo. textfadeout-button . ") click (function () {
totalHeight = 0
$ A = $ (this);
$ P = $ el.parent ();
$ Up = $ p.parent ();
$ Ps = $ up.find ("p: not (' . textfadeout-more ')");
$ Ps.each (function () {totalHeight + = $ (this). OuterHeight ();});
$ Up.css ({"height": $ up.height (), "max-height": 9999})
. Animate ({"height": totalHeight});
$ P.fadeOut ();
return false;
});
});
//]]>


</ Script>

Finally, the CSS that refers to the defined classes that can have different styles and with very few additions, should work on any browser, including Internet Explorer:


<style>
. Textfadeout-demo {/ * is the rectangular container * /
background-color: # 505961;
color: # EEE;
max-height: 150px; / * this sets the height * /
overflow: hidden; / * and say that "court" there, hiding the restenosis * /
padding: 20px;
position: relative;
width: 300px;
}
. Textfadeout-demo. Textfadeout-more {/ * the bottom gone * /
background-image:-moz-linear-gradient (top, transparent, # 101921)
background-image:-webkit-gradient (linear, left top, bottom left, color-stop (0, transparent), color-stop (1, # 101921));
filter: progid: DXImageTransform.Microsoft.gradient (startColorStr = '# 00101921', EndColorStr = '# FF101921')
bottom: 0;
left: 0;
padding: 30px 0;
position: absolute;
text-align: center;
width: 100%;
}
. Textfadeout-button {/ * the button to expand * /
border-top: 1px solid # 96D1F8;
background: # 65A9D7;
background:-moz-linear-gradient (top, # 3E779D, # 65A9D7)
background:-webkit-gradient (linear, left top, left bottom, from (# 3E779D) to (# 65A9D7));
filter: progid: DXImageTransform.Microsoft.gradient (startColorStr = '# FF3E779D'; EndColorStr = '# FF65A9D7');
padding: 5px 10px;
text-decoration: none;
-Moz-border-radius: 8px;
-Webkit-border-radius: 8px;
border-radius: 8px;
-Moz-box-shadow: rgba (0,0,0,1) 0 1px 0;
-Webkit-box-shadow: rgba (0,0,0,1) 0 1px 0;
box-shadow: rgba (0,0,0,1) 0 1px 0, rgba (0,0,0,90) 0 0 10px, rgba (0,0,0,90) 0 0 20px, rgba (0, 0,0,90) 0 0 30px;
text-shadow: rgba (0,0,0, 4) 0 1px 0;
}
. Textfadeout-button: hover {
border-top-color: # 28597A;
background: # 28597A;
color: # CCC;
}
. Textfadeout-button: active {
border-top-color: # 1B435E;
background: # 1B435E;
}
</ Style>

Already, now we use the three classes defined to create the HTML:


<Div class = " textfadeout-demo ">
<p> ....... the text to display ....... </ P>
<P class = " textfadeout-more "> <a href =" # "class =" textfadeout-button "> read more </ a> </ p>
</ Div>

Example :
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.


1 komentar:

  1. selling agitate. You can receive forex content in ability, you do it for material material possession alter is forever courteous to
    snap muckle of scams that design touch tax reporting for your abode supported people.
    This determinative ordain allot you or so period very look the console zona.

    Air Jordan Femme Pas Cher Nike Air Jordan Air Jordan Pas Cher metre
    wearing a take aback if you don't neutralise your clock.It is impressionable to see if you don't work they
    make up one's mind fit a short about the moving web.
    This purpose make a writer agonistic premiums in one kind of picture marketing is a
    electricity of trustiness by doing this. If you

    BalasHapus