2013-08-02 23 views
-1

我有一個與jQuery的網頁。當我在iPad/iPhone中打開它時,超鏈接在爲其設置懸停行爲時無法按預期工作。與iOS上的點擊/懸停行爲混淆與jQuery

我試圖通過瀏覽互聯網上的許多網站,但找不到任何特定的解決方案。也許我無法理解發生了什麼。我會欣賞一些線索和解決方案。

這裏是設置懸停代碼:

.box:hover .box_details .description2 { 
    height: auto !important; 
    display: block 
} 

.box .social { 
    width: 150px ; 
    position: absolute; 
    z-index: 99 ; 
    margin: 0 auto; 
    margin-left: 50%; 
    left: -75px; 
    text-align: center 
} 

.box:hover .social ul { 
    margin-top: 10px; 
    -webkit-transition: margin-top linear 0.5s ; 
    transition: margin-top linear 0.5s ; 
} 

.box .social ul { 
    width: 100% ; 
    float: left ; 
    margin-top: -50px ; 
} 

.box .social ul li { 
    float: left; 
    list-style: none; 
    margin: 1% 1% 0 1%; 
    line-height: 20px; 
    width: 22% 
} 

.box .social ul li img { 
    width: 100% !important; 
    position: relative 
} 

請幫助我。謝謝!

+0

你能告訴我們你的代碼嗎?還......你怎麼能在觸摸屏設備上懸停?無論你是否觸摸它,沒有鼠標光標懸停在元素上... – Th0rndike

+3

iOS中的'懸停'是什麼? –

+0

您可以使用[jQuery Mobile Events](http://api.jquerymobile.com/category/events/)做得更好,嘗試「tap」或「taphold」。 – Mooseman

回答

0

我認爲你可以改變懸停事件來觸摸事件。

+0

如何更改懸停觸摸事件爲我的手機和我墊 – Kamal

+0

如果您使用jQuery,它會像: $(element).on('touchstart',function(){//您的代碼})。 on('touchend',function(){// your code})' – zqillyc

+0

@zqillyc - 不完全。該方法只會在手指觸摸時起作用。 – Redtopia

0

在iOS中,所有懸停事件都被視爲點擊事件。所以,如果你在鏈接上有一個:懸停樣式,用戶將不得不點擊鏈接兩次。 這是一篇關於iOS的文章:hover/double tap issue

1

如果你談論的是jQuery的事件臺式機和移動

$('.selector').on('mouseenter touchstart', function(){ 
    // Do something 
}); 

$('.selector').on('mouseleave touchend', function(){ 
    // Dhing someto 
}); 
+0

這不等同於.hover()。觸摸式菜單需要一個觸摸式開關,後面跟着一個可以保持菜單打開的觸摸屏。然後,當你再次點擊時它需要關閉,這將會產生另一個觸摸點和touchend。 – Redtopia

0

任何網站手機(在iPhone或iPad或任何設備使用)懸停效果是不必要(由於觸摸)它不會有效果。

最好只用:active psuedoclass。