Pure CSS Fish Eye Menu

Pure Css Fish Eye Menu

A pure CSS technique to transform your icon menu into an interactive zooming icon navigation menu inspired from Mac OSX Dock with fish eye effect. One of many ways to style html list tags into interactive, usable, and accessible menu using pure CSS.

What is a Fish Eye Menu?

Fish eye menu is an interactive navigation layout technique where menu icon images are displayed in a linear fashion. These icons respond to the mouse hover by expanding its size to become larger and more visible. The active icon which is under the mouse pointer is fully expanded while the icons before and after the active icon are slightly expanded to mimic the fish eye lens effect.

HTML Mark-up and CSS Code

This CSS technique demonstrates the use of advanced CSS such as the dynamic pseudo-class ":hover" on <li> tags and the adjacent sibling "+" selector for styling image navigation menu as unordered list mark-ups.

The "+" selector allows styling of the item right of the active item and since CSS does not have a selector to style the item on the left, fish eye effect only happens on the right of the active item.

Pure CSS Fish Eye menu works on Internet Explorer 7+ and 8+, Firefox 3+, Google Chrome, Safari 3.2+, Opera 9.52+, and Konqueror 3.5.7+. However, the expanding of images next to the active image with the use of "+" selector only works on IE7+, IE8+, Opera 9.52+, and Konqueror 3.5.7+.

Here are two types of CSS Fish Eye menu: expand-down and expand-up.

  1. Expand-Down Fish Eye Menu

    Expand-Down CSS Fish Eye Menu

    Expands image downwards on mouse over maintaining top alignment. See the demo.

    The HTML Mark-up

    <div class="expand-down">
      <ul>
        <li>
          <a href="http://jigsaw.w3.org/css-validator/check/referer">
            <!-- the image -->
            <img src="/images/demos/w3c-valid-css-trans.png" />
            <!-- the label -->
            <span>Valid CSS</span>
          </a>
        </li>
        <!-- make copies of <li>...</li> block to create more items ... -->
      </ul>
    </div>

    The CSS Rules

    <style type="text/css">
    <!--
    .expand-down {
      font-family:Arial, Helvetica, sans-serif;
      line-height:normal;
      margin-top:20px;
      height:150px;
      width:500px;
      background: url(/images/demos/macosx-style-background.png) no-repeat;
      margin-bottom:30px;
    }
    /* reset margins and paddings */
    .expand-down * {
      margin: 0;
      padding: 0;
    }
    .expand-down ul {
      padding-top:10px;
      margin-left:10px;
    }
    .expand-down ul li {
      float:left;
      list-style-type:none;
    }
    .expand-down ul li a {
      text-decoration:none;
    }
    .expand-down ul li a img {
      width:50px;  /* initial width of images, 50% of width */
      height:50px; /* initial height of images, 50% of height */
      border:none;
    }
    /* initially, don't show the label inside <span> tag */
    .expand-down ul li a span {
      display:none;
    }
    .expand-down ul li:hover a span {
      /* show label on mouse hover */
      display:block;
      font-size:14px;
      text-align:center;
      color:#fff;
    }
    /* expand the image to 100% on mouse hover.
    ** an image becomes active when mouse hovers it
    ** ideally, the image should have same width and height as below 
    */
    .expand-down ul li:hover a img {
      width:100px;
      height:100px;
    }
    /* expand the image next to the right of the active image to 60% using + selector */
    .expand-down ul li:hover + li a img {
      width:60px;
      height:60px;
    }
    /* expand the image second to the right of the active image to 55% using + selectors */
    .expand-down ul li:hover + li + li a img {
      width:55px;
      height:55px;
    }
    -->
    </style>
  2. Expand-Up Fish Eye Menu

    Expand-Up CSS Fish Eye Menu

    Expands images upwards on mouse over maintaining bottom alignment. See the demo.

    The HTML Mark-up

    <div class="expand-up">
    <ul>
      <li>
        <a href="http://jigsaw.w3.org/css-validator/check/referer">
          <!-- label should appear on top of image so it comes first -->
          <span>Valid CSS</span>
          <!-- the image -->
          <img src="/images/demos/w3c-valid-css-trans.png" />
        </a>
      </li>
      <!-- add items by making copies of <li></li> block -->
    </ul>
    </div>

    The CSS Rules

    <style type="text/css">
    <!--
    .expand-up {
      font-family:Arial, Helvetica, sans-serif;
      line-height:normal;
      height:150px;
      width:500px;
      background: url(/images/demos/macosx-style-background.png) no-repeat;
      overflow:visible;
      margin-bottom:30px;
    }
    /* reset margins and paddings */
    .expand-up * {
      margin: 0;
      padding: 0;
    }
    .expand-up ul {
      margin-left:10px;
    }
    .expand-up ul li {
      float:left;
      list-style-type:none;
      /* create a reserved space for expanded image to make this work in ie */
      padding-top:65px;
      /* margin to place the menu at the bottom */
      margin-top:25px;
    }
    .expand-up ul li a {
      text-decoration:none;
    }
    .expand-up ul li a img {
      width:50px;  /* initial width of images, 50% of width */
      height:50px; /* initial height of images, 50% of height */
      border:none;
    }
    /* initially, don't show the label inside <span> tag */
    .expand-up ul li a span {
      display:none;
    }
    .expand-up ul li:hover a span {
      /* show item label on mouse hover */
      display:block;
      font-size:14px;
      text-align:center;
      color:#fff;
      /* move label up to move image up */
      margin-top:-65px;
    }
    /* expand the image to 100% on mouse hover.
    ** again, ideal dimension of image is equal to width and height below
    */
    .expand-up ul li:hover a img {
      width:100px;
      height:100px;
    }
    /* expand the image next to the right of active image to 60% using + selector */
    .expand-up ul li:hover + li a img {
      width:60px;
      height:60px;
      /* move image up by 10px so bottom aligns with other images */
      margin-top:-10px;
    }
    /* expand the image second to the right of active image to 55% using + selectors */
    .expand-up ul li:hover + li + li a img {
      width:55px;
      height:55px;
      /* move image up by 5px so bottom aligns with the other items */
      margin-top:-5px;
    }
    -->
    </style>

Pure CSS Fish Eye Menu Download

Get the complete HTML+CSS code with sample images from the download page.

See it in action at the demo page

Comments
Rafeek
 - CSS
2009-05-14 10:37:40
Good Article on the CSS
George Larson
2009-05-14 15:13:11
Great article! Thanks!!
2009-05-20 11:11:52
Cool tutorial dude! thanks
cambrian
2009-05-23 20:31:20
Cool!I like it.thank you very much!
 - IE 6
2009-05-26 22:39:22
Doesn't work in IE6 so it fails.
2009-05-27 15:03:26
Standard! Hahaha
Sigmoid
2009-07-03 10:32:02
LOL... IE6?

Okay, it seems some people still don't get it. IE6 IS DEAD.

Do you say that PlayStation 3 games "fail" because they don't run on a PS2? Or that modern Windows software "fail" because you can't run them on Windows 95?

Supporting IE6 is not a goal. It might be one in specific corporate intranet based developments, but not on the world wide web!
In fact, everyone should DELIBERATELY drop IE6 support! Any page I create displays as raw text with no style on IE6. It's readable, and if you want pretty stuff, UPGRADE TO A REAL BROWSER.

DON'T SUPPORT IE6! Bury this beast already!
Chris Sargeant
 - THANK YOU
2010-03-17 22:16:23
I saw the comment and it made me sooo happy. It makes me sad to think people are still supporting IE6.

honestly the designers are in charge.

Dont Design for it!!
You're feeding a Rabid Monkey with your bare hands!!
Virgil
 - Advanced CSS in IE6?
2009-05-28 04:18:37
Wish i could make advanced css work in ie6.
However you can easily create same menu with html markups and css styles which are compatible with ie6 but it can't be called advanced css anymore.
 - IE6? What's that?
2009-08-27 03:12:21
The web advances at a speed such that supporting IE6 is a pain in the neck. Not worth it
2009-05-28 18:44:46
Excellent tutorial. I will try it.

Thanks!
 - wow
2009-05-31 12:06:20
Surprisingly short and easy for being so impressive.
2009-05-31 12:19:21
Ok I have it fixed in IE6, it doesn't expand images left and right to one you hovered, but at least it expands that one :) Thing is that IE6 allows :hover just at links. You need to use this little script that fixes that issue ;)

http://www.xs4all.nl/~peterned/csshover.html

And thanks for sharing ;)
Cheers,
S
Pawan
 - Cool
2009-06-01 09:05:48
Good Article...
But can something be done so that the expansion of icons be made slowly... so that this look even more beautiful.
Thanks
Pawan
2009-06-01 17:52:34
Not the prettiest thing, but I give you credit for actually making it pure CSS.

I hate when people claim "pure CSS" only to use so maybe background images that it could essentially be an image map

kudos!
 - More dynamic?
2009-12-11 14:51:22
Aren't there some CSS3 properties that could make the "expansion" more dynamic? I appreciate that they might not be supported in all browsers though.
Jot
 - Cool!
2009-12-17 14:22:23
Excellent tutorial. Thanks! IE6 fails. not this tut.
Kenny
2010-01-03 03:32:31
Is it possible to expand up and down? I'd like to create a navigation bar with the effect of creating a bubble when doing a mouseover. Any way to just expand from the center instead of up or down? Thanks
2010-03-20 20:41:39
Thanks for an explanation. I believe such movable icons attract much more attention and more convenient in usage.
Name:
Email:
 
Website:
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
Please input the anti-spam code that you can read in the image.

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."