2013-05-04 228 views
2

我想有雙重懸停效果,但我不明白。 我想通過離開顯示的圖標來避免轉換。如何使css雙重懸停效果

也許我在這裏得到一些幫助。任何建議都是值得歡迎的。

這裏是我的HTML:

http://jsfiddle.net/CB5Lr/

<div class="block image addMore" style="position: absolute; top: 100px; left: 50px; height: 350px;width:200px;background-color:red;"> 
    <span data-action="fullView" class="shopIcons full_screen_icon"></span> 
    <figure class="with-hidden-caption"> 
     please hover here. after a second a icon will apear in the right corner. 
     <br><br> 
     If you hover the icon it will change. Until here everything is OK.<br><br> 
     But, if you leave the icon, it shout show the old one without the rolling effekt. 
    </figure> 
</div> 

和CSS:

.shopIcons { 
    background: url("http://www.dasunddas.de/img/base/shop_icons.png?v=63") no-repeat scroll 0 0 transparent; 
} 

span.full_screen_icon { 
    background-position: 0px 0px; 
    cursor: pointer; 
    opacity: 0; 
    height: 45px; 
    position: absolute; 
    right: -45px; 
    top: -45px; 
    width: 45px; 
    z-index: 10; 
    transition-duration: .6s; 
    transition-delay: 1s; 
    /* transition: all; */ 
} 

span.full_screen_icon:hover { 
    background-position: 0px -50px; 
    transition-delay: 0s; 
    transition-duration: 0s; 
} 

div.addMore:hover span.full_screen_icon { 
    opacity: 1; 
    right: 0; 
    top: 0; 
} 

http://jsfiddle.net/CB5Lr/

+0

你已經有一個「雙翱翔」,有什麼問題?你想使用較少的標記? – coma 2013-05-04 09:07:33

+0

是的,我有雙重懸停。但是讓第二次懸停產生錯誤的效果。我想避免在背景位置的過渡。它通過離開圖標 – hamburger 2013-05-04 09:10:27

+0

呼籲工作沒有過渡哦,現在我明白了,你應該加上這個問題。 – coma 2013-05-04 09:12:04

回答

1

嗯,我的第一個想法,用:後(或跨度內的另一個元素),因爲在某種程度上,你需要添加其他元素與懸停玩>懸停:

http://jsfiddle.net/CB5Lr/7/

.shopIcons { 
    background: url("http://www.dasunddas.de/img/base/shop_icons.png?v=63") no-repeat scroll 0 0 transparent; 
} 

span.full_screen_icon { 
    background-position: 0px 0px; 
    cursor: pointer; 
    opacity: 0; 
    height: 45px; 
    position: absolute; 
    right: -45px; 
    top: -45px; 
    width: 45px; 
    z-index: 10; 
    transition-duration: .6s; 
    transition-delay: 1s; 
} 

span.full_screen_icon:after { 
    content: ""; 
    display: none; 
    width: 45px; 
    height: 45px; 
    position: absolute; 
    top: 0; 
    left: 0; 
    background: url("http://www.dasunddas.de/img/base/shop_icons.png?v=63") no-repeat scroll 0 -50px transparent; 
} 

span.full_screen_icon:hover:after { 
    display: block; 
} 

div.addMore:hover span.full_screen_icon { 
    opacity:1; 
    right: 0; 
    top: 0; 
} 

這是棘手!

+0

thx昏迷它看起來相當不錯。現在有什麼不同,當我離開addMore-Area時,它不會再飛出去了。 – hamburger 2013-05-04 09:35:32

+0

我更新了我的jsfiddle,是這樣嗎? – coma 2013-05-04 09:40:19

+0

現在看起來非常好。非常感謝http://jsfiddle.net/CB5Lr/7/我永遠不會得到它... – hamburger 2013-05-04 09:45:39