ご存知かもしれ:hover
ませんが、タッチ スクリーン デバイスには存在しません。したがって、レスポンシブ Web サイトを設計するときは、:hover インタラクションをいつどこで使用するかを慎重に計画する必要があります。
これはモバイル デバイスに実装されていますが、主に iOS デバイスで非常にバグが多くなっています。一方、:focus
フォーカスをサポートする要素でのみ使用できるため、タグとボタンは除外されるため、使用できません。また:active
、モバイル デバイスでは使用できません。
この場合、jQuery を使用してこの問題を解決できます。
作業例: http://jsfiddle.net/Gajotres/84Nug/
この例ではvmousedown
、 vmouseup
とvmousecancel
イベントを使用したので、デスクトップ/モバイル デバイスで同様にテストできます。touchstart
それらを, touchend
およびに置き換えるだけtouchcancel
です。
touchcancel
/vmousecancel
ボタンが押された状態のままになることがあるため、必要です。
コード:
$(document).on('pagebeforeshow', '#index', function(){
$(document).on('touchstart','.custom_header' ,function(){
$(".custom_header").css("background","url('http://www.cesarsway.com/sites/default/files/cesarsway-images/features/2012/March/Puppies-and-Exercise.jpg') no-repeat center");
}).on('touchend', function(){
$(".custom_header").css("background","red");
}).on("touchcancel", function() {
$(".custom_header").css("background","red");
});
});