2011-05-30 64 views
3

我只是碰到这个家伙的网站偶然发现:http://mantia.me/透明PNG反应到网站的图片滑块和内容

他有一个真棒标志,反应到网站目前显示的内容,如果你等待他的主页标识的变化与幻灯片放映的图像。我想知道是否有人知道如何复制效果。我猜这是一个带有旋转主背景的透明PNG,然后该网站位于顶层,但我可能是错的。

任何猜测如何做类似的东西?

图片:enter image description here enter image description here

回答

6

这真的很简单他有什么。就像你提到的那样,它是一个透明的PNG,与给定的背景相匹配(在这种情况下是白色),并将其放置在顶部z-index。剩下的仅仅是带有fadeInfadeOut图片的jQuery。

您可以查看图像转换顶部的png。 enter image description here

所以基本上你只需要一个divposition:relative设置它的宽度的高度;然后在里面添加另一个div它有jQuery幻灯片(检查出:http://medienfreunde.com/lab/innerfade/),将其设置为z-index:0然后添加另一个div(它将在滑块顶部)并将它添加backgroundz-index到高于0的东西以及你很好走。

+0

请注意这是**解释**;让你明白**它是如何工作的。而不是给你完整的代码(**勺喂养不好**)。我认为理解它如何工作而不是仅仅复制粘贴是很有价值的。 – MarioRicalde 2011-05-30 17:59:43

+0

关键图像是一个名为“nav.png”的图像。 – Pointy 2011-05-30 18:00:48

+0

确实。它包含背景上的TEXT表单。 – MarioRicalde 2011-05-30 18:02:30

1

这里是他是如何做:

HTML

<div id="content"> 
    <div id="feature"></div> 
    <div id="navigation"></div> 
</div> 

CSS

#content { 
    position: relative; 
    width: 800px; 
    margin: 64px auto; 
    font: normal 13px/16px "myriad-pro-1","myriad-pro-2", sans-serif; 
    color: #404040; 
} 

#navigation{ 
    position: absolute; 
    z-index: 1000; 
    top: 0; 
    left: 0; 
    width: 800px; 
    height: 46px; 
    background: transparent 
     url(http://mantia.me/wp- content/themes/minimalouie/img/nav.png) 
     no-repeat top left; 
} 

#feature { 
    width: 800px; 
    height: 466px; 
    overflow: hidden; 
    background-color: aqua; 
} 

然后,他只是增加了一个img元素#feature

<div id="feature"> 
    <img src="http://mantia.me/images/supermariobros_large.jpg" 
     alt="Super Mario Bros."> 
</div> 

请参阅fiddle