• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com专业计算机教程网站
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • html/xhtml
  • html5
  • CSS
  • XML/XSLT
  • Dreamweaver教程
  • Frontpage教程
  • 心得技巧
  • bootstrap
  • vue
  • AngularJS
  • HBuilder教程
  • css3
  • 浏览器兼容
  • div/css
  • 网页编辑器
  • axure
您的位置:首页 > 网页设计 >CSS > css 背景图片定位在菜单效果中的应用实例

css 背景图片定位在菜单效果中的应用实例

作者:佚名 字体:[增加 减小] 来源:互联网 时间:2017-08-06

本文主要包含css,背景图片定位,菜单效果等相关知识,佚名 希望在学习及工作中可以帮助到您
这款菜单大家需要注意HOVER状态下背景图片定位发生了变化,从而实现了这样的效果。

本实例是一位国外的朋友所写,不进行任何翻译,直接发出来,大家可以偿试阅读,如果遇到困难可以求助于翻译软件。
不断的提高自己的英文阅读能力也是我们一直所提倡的,让我们一起努力吧!

Overview
  Here are the required graphics to assembe the menu


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


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).


  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.


  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.


  Repeat this step for the other buttons. You should have the follow 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)


#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 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 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:hover
  When mouseover the link, we want to shift the background image from top to bottom.


#menu a:hover span
  When mouseover the link, we want the span element to 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 span
  Here we are specifying the width, height, background, and position of the span element of .home (mouseover GIF image)


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


#menu .rss
  Repeat this step for .rss

 Example Source Code

您可能想查找下面的文章:

  • css小技巧
  • 各大网站CSS初始化代码
  • css权重问题
  • CSS实现鼠标上移图标旋转效果
  • 使用CSS3制作一个简单的进度条(demo)
  • 用纯CSS实现饼状Loading等待图效果
  • 利用CSS3伪元素实现逐渐发光的方格边框
  • CSS3实现内凹圆角的实例代码
  • 利用HTML5+CSS3实现3D转换效果实例详解
  • css3+伪元素实现鼠标移入时下划线向两边展开的效果

相关文章

  • 2017-08-06CSS3 flex布局之快速实现BorderLayout布局
  • 2017-08-06png图片在ie8浏览器下有黑色边框的解决方法
  • 2017-08-06规范HTML代码可以节省修改代码的时间
  • 2017-08-06用ul li实现边框重合并附带鼠标经过效果
  • 2017-08-06ie6 fixed bug的解决方法 (css+js)
  • 2017-08-06css中省去绝对地址前的http: 节省字节
  • 2017-08-06仿Word自动套用格式使用CSS设置表格样式实例
  • 2017-08-06CSS3 Notes: -webkit-box-reflect实现倒影的实例
  • 2017-08-06IE10 CSS Hack介绍及IE11的CSS Hack提前了解
  • 2017-08-06再谈动态添加样式规则的方法

文章分类

  • html/xhtml
  • html5
  • CSS
  • XML/XSLT
  • Dreamweaver教程
  • Frontpage教程
  • 心得技巧
  • bootstrap
  • vue
  • AngularJS
  • HBuilder教程
  • css3
  • 浏览器兼容
  • div/css
  • 网页编辑器
  • axure

最近更新的内容

    • 纯css实现的tab切换效果(使用锚点作为标记)
    • Less框架中将CSS强制打包到单个文件中的技巧
    • 一款纯css3实现的竖形二级导航的实例教程
    • CSS3中:nth-child和:nth-of-type的区别深入理解
    • CSS 避免使用滤镜
    • 简析CSS表达式attr()的运用
    • CSS属性探秘系列(六):margin
    • 使用CSSgram来实现类似Instagram上的简单的滤镜效果
    • CSS美化 input type=file 兼容各个浏览器
    • 什么是CSS3 HSLA色彩模式?HSLA模拟渐变色条

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有