如何在本网站中实现类似的悬停效果
当您将链接悬停在顶部时如何实现效果(主页,关于,工作) 您可以在 http://www.webdesignerwall.com/ 中看到, 有人可以给我提示吗?或任何?
how do you achieve the effects when you hover the links at top(HOME,ABOUT , JOBS)
which you can see in http://www.webdesignerwall.com/ ,
can someone give me a hint ? or any?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
这里的很多人都太快地想出了脚本语言。啧啧。这可以通过 CSS 来实现。我什至倾向于说没有必要额外加价。人们可以在 :hover 状态下使用背景图像。简单的。
A lot of people here are far too quick to whip out the scripting languages. Tsk, tsk. This is achievable through CSS. I'd even be inclined to say that there is no need for additional mark-up. One could use a background image on the :hover state. Simple.
每个链接 (#nav li a) 包含导航项文本以及默认设置为“display:none”的附加范围。跨度还有一组与其位置和背景图像(即显示的文本)相关的其他样式。
在 #nav li a:hover 上,跨度变为 display:block,这使其在定义的位置可见。无需编写脚本。
HTML
CSS:
当然,这是一个完全精简的版本,您需要添加自己的定位和其他适当的样式。
Each link (#nav li a) contains the nav item text plus an additional span which is set to "display:none" by default. The span also has a set of other styles relating to its position and background-image (which is the text that appears).
On #nav li a:hover the span becomes display:block, which makes it visible at the defined position. No scripting needed.
HTML
CSS:
This is a completely stripped down version of course, you will need to add your own positioning and other styles as appropriate.
有很多很多方法可以实现这一目标。最简单的方法是让每个导航项更改上面的图像以反映其相应的图形。
-- jQuery
There are many, many ways this could be acheived. The simplest would be to have each navigation item change the above image to reflect its corresponding graphic.
-- jQuery
其实现方式是使用空的
。
默认情况下,它位于屏幕外,并在悬停时移入视图,
如下所示:
CSS:
The way it's achieved is by using an empty
<span>
.It's positioned off screen by default and move into view on hover
Like so:
And the CSS:
它可能是“主页”、“关于”和“工作”链接上的一个脚本,使浮动 div 标签在鼠标悬停时可见,而在鼠标移出时不可见。
这是一个实现类似效果的简单代码示例:
It is probably a script on the Home, About and Jobs links that makes a floating div tag visible on mouseover and invisible on mouseout.
Here is a simple code example achieving a similar effect:
使用 jQuery 你只需要做类似的事情
Using jQuery you would just do something like
事实上,你可以在翻转时翻转整个区域,我建议这只是使用 CSS 出现在翻转时的替代背景。然后,元素本身可能会被绝对定位在导航容器内。
by the fact that you can rollover the whole area when on rollover i would suggest that it is simply an alternative background that appears on rollover using css. the elements themselves might then be positioned absolutely within the navigation container.
在这个特定的实例中,开发人员在构成菜单的 li 元素内放置了一个 span 标签。该跨度具有(最显着的)以下属性:
之后,只需一些 JavaScript 即可使跨度出现/消失。
In this particular instance, the developer placed a span tag inside the li elements that make up the menu. That span has (most notably) these properties:
After that, just some JavaScript to make the span appear/disappear.
Eric Meyer 网站上解释了纯 CSS 解决方案:纯 CSS 弹出窗口 2。
A pure CSS solution is explained on Eric Meyer site: Pure CSS Popups 2.