<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Sealyu

    --- 博客已遷移至: http://www.sealyu.com/blog

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      618 隨筆 :: 87 文章 :: 225 評論 :: 0 Trackbacks

    Last tutorial, I showed you how to design a watercolor effect menu in Photoshop. This tutorial I will show you how to slice up the menu design (step by step) and put them together with CSS. Most of you probably know how to code a horizontal or vertical CSS list menu. Now let’s take it to the next level — code an advanced (un-typical) list menu utilizing the CSS position property.

    View Demo CSS menu

    Download Demo ZIP

    Overview

    Here are the required graphics to assembe the menu (you can download from the zip).

    required graphics

    1. Main background

    Open the Photoshop file. Turn off the menu text Layer Group and save the main background as menu-bg.jpg.

    screen 2

    2. Button graphics

    Turn off the background Layer Group and leave only the menu text layers visible. Make a rectangle selection cover the "home" item, go to menu Edit > Copy Merged (Cmd + Shift + C).

    screen 3

    Create a new file and take note of the file dimension (w x h), in my case the "home" graphic is 144 x 58px. Paste the "home" graphic in the new file. Go to menu Image > Canvas Size, adjust the image height x 2 (58 + 58 = 116px). Duplicate the home graphic layer and align it to the bottom. Erase the highlight strokes in the upper layer.

    screen 4

    Here is how the hover effect will work. We will set the link button to 144 x 58px, when mouseover, we will shift the background image from top to bottom.

    screen 5

    Repeat this step for the other buttons. You should have the follow graphics:

    required graphics

    3. HTML source

    When you are done with the graphics, let’s start coding. Start with an un-ordered list <ul>.

    • note there is an id="menu" assigned to the<ul> tag
    • an unique class name assigned to each link <a>
    • an empty <span> tag (the purpose of this is to make the mouseover effect)
    <ul id="menu">
    <li><a href="#" class="home">Home <span></span></a></li>
    <li><a href="#" class="about">About <span></span></a></li>
    <li><a href="#" class="rss">RSS <span></span></a></li>
    </ul>

    #menu

    Reset the menu to no padding, no margin, and no list-style. Specify the width and height same dimension as the menu-bg.jpg. Then attach the menu background image. The key point to remember here is set the position property to relative.

    #menu {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 774px;
    height: 210px;
    background: url(images/menu-bg.jpg) no-repeat;
    position: relative;
    }

    #menu span

    Specify the span element to display:none (so they will be invisible by default). Specify position:absolute, so we can place the mouseover GIF image on exact position.

    #menu span {
    display: none;
    position: absolute;
    }

    #menu a

    The key point here is the text-indent property. We specify the text-indent property with a negative value (-900%), so the text will be hidden.

    #menu a {
    display: block;
    text-indent: -900%;
    position: absolute;
    outline: none;
    }

    #menu a:hover

    When mouseover the link, we want to shift the background image from top to bottom.

    #menu a:hover {
    background-position: left bottom;
    }

    #menu a:hover span

    When mouseover the link, we want the span element to display:block.

    #menu a:hover span {
    display: block;
    }

    #menu .home

    Specify the width, height, and background image. Since we already specified all <a> element postition:absolute in previous step, now just say where the .home button should be by specifying the left and top property.

    #menu .home {
    width: 144px;
    height: 58px;
    background: url(images/home.gif) no-repeat;
    left: 96px;
    top: 73px;
    }

    #menu .home span

    Here we are specifying the width, height, background, and position of the span element of .home (mouseover GIF image)

    #menu .home span {
    width: 86px;
    height: 14px;
    background: url(images/home-over.gif) no-repeat;
    left: 28px;
    top: -20px;
    }

    #menu .about

    Copy the .home rules and rename them to .about. Now just change the width, height, background, left, and top property.

    #menu .about {
    width: 131px;
    height: 51px;
    background: url(images/about.gif) no-repeat;
    left: 338px;
    top: 97px;
    }
    #menu .about span {
    width: 40px;
    height: 12px;
    background: url(images/about-over.gif) no-repeat;
    left: 44px;
    top: 54px;
    }

    #menu .rss

    Repeat this step for .rss

    #menu .rss {
    width: 112px;
    height: 47px;
    background: url(images/rss.gif) no-repeat;
    left: 588px;
    top: 94px;
    }
    #menu .rss span {
    width: 92px;
    height: 20px;
    background: url(images/rss-over.gif) no-repeat;
    left: 26px;
    top: -20px;
    }

    All in one:

    #menu {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 774px;
    height: 210px;
    background: url(images/menu-bg.jpg) no-repeat;
    position: relative;
    }
    #menu span {
    display: none;
    position: absolute;
    }
    #menu a {
    display: block;
    text-indent: -900%;
    position: absolute;
    outline: none;
    }
    #menu a:hover {
    background-position: left bottom;
    }
    #menu a:hover span {
    display: block;
    }

    #menu .home {
    width: 144px;
    height: 58px;
    background: url(images/home.gif) no-repeat;
    left: 96px;
    top: 73px;
    }
    #menu .home span {
    width: 86px;
    height: 14px;
    background: url(images/home-over.gif) no-repeat;
    left: 28px;
    top: -20px;
    }

    #menu .about {
    width: 131px;
    height: 51px;
    background: url(images/about.gif) no-repeat;
    left: 338px;
    top: 97px;
    }
    #menu .about span {
    width: 40px;
    height: 12px;
    background: url(images/about-over.gif) no-repeat;
    left: 44px;
    top: 54px;
    }

    #menu .rss {
    width: 112px;
    height: 47px;
    background: url(images/rss.gif) no-repeat;
    left: 588px;
    top: 94px;
    }
    #menu .rss span {
    width: 92px;
    height: 20px;
    background: url(images/rss-over.gif) no-repeat;
    left: 26px;
    top: -20px;
    }

    Done

    That’s it. You can preview my CSS menu.

    Note: there is an IE6 bug where the <span> hover effect doesn’t display properly. To fix that, you can use Javascript to specify the <span> to display block on mouseover.

    posted on 2009-09-23 09:41 seal 閱讀(370) 評論(0)  編輯  收藏 所屬分類: CSS
    主站蜘蛛池模板: 日本免费一区尤物| 亚洲v高清理论电影| 亚洲综合精品伊人久久| 0588影视手机免费看片| 亚洲男女性高爱潮网站| 日日麻批免费40分钟日本的| 亚洲精品国产成人中文| 亚洲精品免费网站| 中文字幕无码亚洲欧洲日韩| 免费无码又爽又刺激毛片| 羞羞视频免费观看| 亚洲欧洲一区二区三区| 一级有奶水毛片免费看| 亚洲精品免费观看| 99久久久国产精品免费无卡顿| 亚洲一区二区久久| 成在线人永久免费视频播放| 色老头综合免费视频| 久久精品国产亚洲综合色| 19禁啪啪无遮挡免费网站| 亚洲男人天堂2020| a级毛片高清免费视频就| 精品亚洲国产成AV人片传媒| 波多野结衣中文字幕免费视频| 亚洲五月综合缴情婷婷| 四虎永久精品免费观看| a级男女仿爱免费视频| 亚洲国产一区在线观看| 国产成人青青热久免费精品| 国产精品免费久久久久影院 | 无码日韩精品一区二区免费暖暖| 久久青青草原亚洲av无码app| 在线视频观看免费视频18| 黄网站在线播放视频免费观看| 国产精品亚洲二区在线观看 | 国产精品美女自在线观看免费 | 99re热精品视频国产免费| 亚洲中文字幕无码av| 在线亚洲午夜理论AV大片| 亚洲免费电影网站| 一区在线免费观看|