I really like how twitter blur the end of the long name, when you move the cursor on the box with message.
I would like to try make something similar, with a little difference - I have a DIV (let's say width: 100px;) and when a text inside is longer then 100px - then will be the end of the respective text blurred...
Could anyone give me some example/source/advice, how to do that?
Thank you
With the following HTML:
<div>
<span>@someUserName</span>
</div>
And CSS:
span {
display: inline-block;
position: relative;
}
span::after {
position: absolute;
top: 0;
bottom: 0;
right: 0;
width: 3em;
content: '';
background: -moz-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(255,255,255,0)), color-stop(100%,rgba(255,255,255,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, rgba(255,255,255,0) 0%,rgba(255,255,255,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, rgba(255,255,255,0) 0%,rgba(255,255,255,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left, rgba(255,255,255,0) 0%,rgba(255,255,255,1) 100%); /* IE10+ */
background: linear-gradient(left, rgba(255,255,255,0) 0%,rgba(255,255,255,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00ffffff', endColorstr='#ffffff',GradientType=1 ); /* IE6-9 */
}
JS Fiddle demo.
You can, of course, also use percentage widths in the generated content: JS Fiddle proof of concept.
Edited in response to comments, below, reporting that IE 8 (and presumably lower) doesn't work with the above solution:
not working for me in IE8 though...
I've updated the HTML to the following:
<div>
<span>@someUserName
<!--[if ie]>
<span class="ieFadeout"></span>
<![endif]-->
</span>
</div>
And updated the CSS:
div > span {
display: inline-block;
position: relative;
}
div > span::after {
position: absolute;
top: 0;
bottom: 0;
right: 0;
width: 3em;
content: '';
background: -moz-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(255,255,255,0)), color-stop(100%,rgba(255,255,255,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, rgba(255,255,255,0) 0%,rgba(255,255,255,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, rgba(255,255,255,0) 0%,rgba(255,255,255,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left, rgba(255,255,255,0) 0%,rgba(255,255,255,1) 100%); /* IE10+ */
background: linear-gradient(left, rgba(255,255,255,0) 0%,rgba(255,255,255,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00ffffff', endColorstr='#ffffff',GradientType=1 ); /* IE6-9 */
}
span > .ieFadeout {
position: absolute;
top: 0;
right: 0;
bottom: 0;
width: 3em;
background-color: transparent;
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00ffffff', endColorstr='#ffffff',GradientType=1 ); /* IE6-9 */
}
JS Fiddle demo, working in Win XP/IE 8, and Chrome 18 (as before).
References:
You place another DIV right on top of that and give it a semi-transparent PNG background, which fades from completely transparent to completely white. Something like:
<div style="position: relative; width: 100px">
@GuyKawasaki
<div style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; background-image:url(overlay.png)"></div>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With