3 new and amazing CSS tricks every web designer must know
Yesterday evening, I decided to create a nice layout based on typography and the text-shadow property. I took some time to imagine new interesting ways to use this CSS property.
Then, I tried to turn what I imagined into reality. And it worked!
CSS only navigation blur
Many of us know the famous blur CSS menu trick the end result is great, no doubt, but you need to write a lot of code and to use sprites. In two words, that’s “not easy”.
![]()
I’ll show you how to do that with less code, and no picture. Here is a demo if you want to see before your code. (Please use an up-to-date, standard compliant, browser: Firefox, Opera or Safari.)
The HTML is just an unordered list, with links inside:
<li><a href="#" title="">Index</a></li>
<li><a href="#" title="">Lyrics</a></li>
<li><a href="#" title="">Dreams</a></li>
<li><a href="#" title="">Feathers</a></li>
<li><a href="#" title="">Beyond</a></li>
<ul>
Now we want the whole list to change when we hover a link (blur). Moreover, we want the link we hover to react differently. Here is what we can do in CSS:
background: #000;
float: right;
list-style-type: none;
}
ul.blur-menu:hover li {
margin-top: -100px;
padding-bottom: 100px;
text-shadow: 0 100px 3px #fff;
}
ul.blur-menu:hover li:hover {
color: #fff;
text-shadow: 0 0 1px #fff;
margin-top: 0px;
padding-bottom: 0px;
}
ul.blur-menu li {
float: left;
margin: 0;
padding: 0 0 0 20px;
text-shadow: 0 0 10px #000;
}
ul.blur-menu li a {
color: #fff;
text-decoration: none;
}
Nice, isn’t it? Now that you have the basic idea, you can play and have fun with this trick to create simple but eye-catching menus!
Simple but effective gradients
Many websites use some kind of gradient, bokeh effects, or light effects. But, it has lots of limitations: the gradient makes the picture heavier, it’s not dynamic, etc.
![]()
Here is a little trick to make a CSS only gradient. You can modify it easily to create bokeh effect, snowflakes, shiny stars, or whatever you want. (By the way, you can check the demo here.)
In your HTML put:
<div>I love the shadow property!</a>!
<span class="highlight">▬</span>
</div>
(You can change the special character inside the <span> with anything you like, and so will change the shape of the highlight.)
Now the CSS:
background: #000;
color: #fff;
}
#style {
margin: 0 auto;
width: 920px;
padding: 20px;
text-align: center;
position: relative;
overflow: hidden;
height: 800px;
}
span.highlight {
position: absolute;
font-size: 300px;
line-height:1px;
text-shadow: 0 200px 400px #FFF;
left: 320px;
top: -280px;
}
That’s nice, but we want to make it dynamic, right? So let’s change the HTML and add some links:
<div>I love <a href="#" title="">Blood</a>, yes <a href="#" title="">Blood</a>!
<span class="highlight">▬</span>
</div>
Now we can make the highlights change when you hover the links. Simply add this to the CSS you just wrote:
position: absolute;
font-size: 300px;
line-height:1px;
text-shadow: 0 200px 400px #FF0000;
left: 320px;
top: -280px;
}
Easy but powerful!
Beautiful typography
The last little trick is a mix between text-shadow and opacity in order to create a beautiful typography. I can’t wait to show you the result, so… here it is:
![]()
I love this effect because it’s very subtle. And it’s easy to create too:
<h1>My lemon juice please...</h1>
<span class="shadow-heading">My lemon juice please...</span>
</div>
I overdid it a little for the CSS, but I don’t know what kind of reset you use so… I’d better be careful:
background: #70D700;
color: #fff;
}
#style {
margin: 150px auto;
width: 920px;
padding: 0 20px;
text-align: center;
position: relative;
overflow: hidden;
}
h1 {
font-style: normal;
font: 42px/1.5 'Palatino Linotype', Palatino, Baskerville, Georgia, serif;
margin:0;
padding:0;
font-weight: normal;
margin-top: 1.2em;
margin-bottom: 1em;
text-shadow: 0px 1px 20px #FDFF00;
}
span.shadow-heading {
font-style: normal;
font: 42px/1.5 'Palatino Linotype', Palatino, Baskerville, Georgia, serif;
padding-top: 1.2em;
padding-bottom: 1em;
position: absolute;
left: 0;
top: 0;
display: block;
width: 960px;
text-shadow: 1px 1px 2px #0C4F00;
}
What now?
These awesome little tricks should have given you many ideas. So enjoy, and try to create your own effects. I know that the text-shadow property and IE are not friends, but that’s not a reason to ignore how powerful it is!
Tomorrow I’ll release a FREE template using all these tricks. Be sure to stay tuned: follow me on Twitter and grab the RSS.
Do you know any good trick with the text-shadow property? Please, share!
Related Posts
You may want to check out the following related posts:
Mars
November 5th
perfect css tricks, thanks for sharing
Like or Dislike:
0
0
Affordable Web Design Company
November 5th
Great tips – thanks!!
Like or Dislike:
0
0
Leon
November 5th
Like the gradient en typography css tricks. The blurred menu doesn’t do the trick for me. It screws up whatever you’re doing on the rest of a website to make it more usable. How is someone supposed to know what the other pagenames are when his cursor is on a hover state?
Like or Dislike:
0
0
Memoryweaver
November 5th
Interesting. I’m sure that blur technique has some other applications – could be interesting combined with CSS3 animations. I’ll have to have a play. Shame about ‘the browser that must not be named’…
Like or Dislike:
0
0
Martin
November 5th
Yhea great trick, specialy the blur…Thanks again.
Like or Dislike:
0
0
Memoryweaver
November 5th
Quick follow-up – yes, animation works, at least for 1 level of text shadow, in Chrome and Safari. CSS transitions should be supported in Firefox 3.7 too (they currently work in the Minefield test version). Looks like things are shaping up nicely, if only we can ‘deal’ with the ‘other’ 65% of users…
Like or Dislike:
0
0
Geert
November 5th
Hope you do realise that only Firefox 3.5 / Safari / Opera / Chrome users may see these effects. That’s about 10-40% of visitors estimated, depending on demographic. Other than that, nice effects!
Like or Dislike:
0
0
Tsedaka
November 6th
@Leon
As I said in the tutorial, please use an updated Firefox/Safari/Opera browser… or everything will go wrong.
@Memoryweaver @Geert
Yes… I do realize that only around 30% of the visitors can see these effects. But hopefully, this number will increase soon. So it’s good to get ready.
Moreover, you can have alternative solutions in your ie.css file :)
Like or Dislike:
0
0
designfollow
November 6th
thanks for this great tricks
Like or Dislike:
0
0
WPExplorer
November 6th
Wow, these are some cool tricks. Thanks. I wonder how they look like in ie6 though…since clients I work with are always worried about that.
Like or Dislike:
0
0
Website Designer
November 6th
Wow Great tips Specially navigation blur it’s very good with less code. Thank you for sharing.
Like or Dislike:
0
0
joe
November 6th
These did not work on my browser.. I am using Firefox with a Mac..
Like or Dislike:
0
0
joe
November 6th
Oh.. now I see where it says that it works on only the latest Firefox.. I cannot upgrade to it because it does not support Applescript yet.
Keep in mind that people often have specific reasons that they can’t upgrade..
Like or Dislike:
0
0
mupet
November 6th
Nice tutorial, thnaks for sharing
Like or Dislike:
0
0
Bill in Detroit
November 6th
If you blur the selected link, then the rest would remain legible. Right?
Who am I kidding … I couldn’t code my way out of a bowl of oatmeal. Nor would I want to, with all this talent around!
Like or Dislike:
0
0
Colum
November 7th
The 1st one is great! Never knew you could do that
Like or Dislike:
0
0
minanube
November 7th
Wow nice trick, especially for blur effect love it :)
Like or Dislike:
0
0
clippingimages
November 7th
Really cool CSS Tricks. Thanks for sharing this nice post. :)
Like or Dislike:
0
0
Helena
November 7th
I am a newbie when it comes to do menus.
I´m wondering how I can for example move the menu a bit down in a layout?
What do I have to change?
Like or Dislike:
0
0
Linux User
November 7th
Not working in Firefox 3.0 in Linux …
Like or Dislike:
0
0
Edward
November 7th
Psst, you forgot to link to the beautiful typography page.
I um… found it .. lying around.. http://www.woobzine.com/files/demos/beautifultypo/typography.php
Like or Dislike:
0
0
robsku
November 7th
I would say that the navigation blur is not exactly something I would find pleasant to view at all, navigation menu should be clearly visible without me having to wave a mouse over it (I use keyboard for navigating anyway so it would be even more trouble for me personally than for average mouser who by default already has his hand on mouse).
As for effects not showing on large percentage of clients, I personally don’t mind that if the effects used are selected with good taste so that the page looks great without them and even better with them – that way they become just enhancements with no harm done from lack of them.
Like or Dislike:
0
0
Tsedaka
November 8th
@Helena
The problem with text-shadow is the direction > right / bottom. Moreover, you can’t just move your text left with text-indent because the shadow would move too.
In other words, if you menu is at the top or left, you can use this trick. Else, it’s more difficult.
@Edward
The idea behind these tricks is to make people aware of the power of CSS. To be honest, I wouldn’t use any of these (well maybe the last one) in a “real” project.
But it’s always good to open your mind and widen your skills ^^
Like or Dislike:
0
0
Bogdan Pop
November 9th
I don’t see anything good in the blurry effect. After you hover one element in the menu, you cave no clue whatsoever as to what other links are about. Pointless.
Like or Dislike:
0
0
Tsedaka
November 10th
@Bogdan Poop
Seriously guy, read the others comments. Try again with the last version of Firefox, Opera, Safari or Google chrome…
Like or Dislike:
0
0
BEBEN
November 10th
i love blur theme…thank’s for the tutorial…so usefull
Like or Dislike:
0
0
Pat Long
November 12th
Any way to adapt this to vertical nav?
Like or Dislike:
0
0
Tsedaka
November 16th
Yes, but it can be tricky :)
Try and have fun… that’s the best way to learn!
Like or Dislike:
0
0
Xtence
November 20th
Great tricks, but there’s an issue with the blur menu on IE (what did you expect) Nice !
Like or Dislike:
0
0