Just Talk About Web

Techniques Behind Modern Web

Tutorials



CSS Web 2.0 Glossy Text


Well, you don’t need to be a Photoshop pro to create glossy text that seems very trendy today (Web 2.0 styles? hmm).

css gradient effect

Here is a simple CSS trick to show you how to create gradient text effect with a PNG image (pure CSS, no Javascript or Flash). Just put an empty <span> tag in the heading and apply the background image overlay using the CSS position:absolute property. This trick works on most browsers: Firefox, Safari, Opera, and even Internet Explorer 6 (with a small CSS hack).

The code looks like this:

<h1><span></span>Just Talk About Web</h1>

Use the CSS to define styling of the H1. Make sure that you set position property to relative;.

1
2
3
4
5
6
7
8
 
h1 {
 /* optional styling, you can use whatever you wish */
 font: bold 300%/100% "Lucida Grande";
 color: #000;
 /* now, this is important */
 position:relative;
}

Now the gradient: we put a transparent PNG as a background image for the span element and set position property to absolute so it can go above the text.

1
2
3
4
5
6
7
8
 
h1 span, h2 span {
 background: url(gradient-glossy.png) repeat-x;
 position: absolute;
 display: block;
 width: 100%;
 height:27px;
}

Unfortunately, not all browsers support PNG transparency (IE6, for example). So for those browsers, please include this as well.

1
2
3
4
5
6
7
<!--[if lt IE 7]>
	h1 span {
	  background: none;
	  filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='gradient-glossy.png', sizingMethod='scale');
	}
 
<![endif]-->

Now, see what we have:

CSS Glossy Text

Look cool? Please note that you can use any text color you want and you can vary gradient effect as long your gradient color is the same as your background color.

View demo here and download demo files here.

Share and Enjoy:

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • StumbleUpon
  • DZone
  • del.icio.us
  • Reddit
  • Mixx
  • Technorati
  • Sphinn
  • Facebook
  • Google
  • SphereIt
  • BlinkList
  • Furl
  • Ma.gnolia
  • Slashdot
  • Spurl
  • TailRank
  • TwitThis
  • 5 Comments
  • Filed under: CSS, Tutorials, Web 2.0
  • Top SEO Tips for Wordpress Blog

    I just want to share the best SEO tips (among a lot of other recommended tips) that work very well for my Wordpress blog. 1. Permalinks Change your Wordpress permalinks to be search-engine friendly. To change the default link type, go to Options -> Permalinks. Select the more search-engine-friendly option: Please read a very comprehensive article about Wordpress permalinks from Web Tool Collections. 2. Create ...

  • 15 Comments
  • Filed under: Tutorials, Web 2.0
  • Rails 2.0 reveals many changes and improvements, but the biggest change involves getting closer to the full web-orientation of REST and HTTP. With a few lines of codes now you can easily create open web applications based on modern web service. Creating Rails application This example is a deadly-simple bookstore CMS. All you can do are to get book list, add or ...









    Free Advertising Free Annual Credit Report

    BlogRush


    Jobs

    Web Hosting

    DreamHost promotion code (use it on registration):

    JTAW - $50 off for all plans ($30 off for monthly plan).

    JTAW2 - 1 extra FREE lifetime unique IP and $30 off for one year or above plans.

    Advertisements

    Blog Promotion