I have used jQuery to add a css transition effect when the mouse hovers over the header of my site, causing it to turn from transparent to a white background.
I'm having a really strange and unexpected problem on touchscreen devices when adding the additional class (.active
).
I can only assume this happens on all touchscreen devices, as I only have my iPhone to test it with, but when I tap my thumb on the header, the whole header is covered in a dark rectangle (as if it were a hyperlink that had just been clicked).
Not only does this look very strange, it is ruining the functionality of the website because I can no longer tap the logo/home link or the button within the header.
I have tried various CSS rules inside a media query to stop this, including setting the .active
class to display:none
and pointer-events:none
, but nothing has been able to fix it.
UPDATE
Here is my actual website code. There's a lot here, but I can't seem to replicate this properly in a JSFiddle.
HTML:
<header class="header">
<div class="header-container">
<h5 class="logo" id="lucieaverill">LUCIE AVERILL</h5>
<h5 class="logo" id="photography">PHOTOGRAPHY</h5>
<div class="mobile-menu">
</header>
CSS:
.header {
width: 100%;
height: 100px;
position:absolute;
top:0;
z-index:2;
transition: all 0.4s;
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
}
.header.active {
background-color:#fff;
}
.header-container {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
justify-content: space-between;
-webkit-justify-content: space-between;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
height:inherit;
width:85%;
max-width:1600px;
overflow:hidden;
}
a.logo {
height:15px;
font-family: ProximaNovaW01-Bold, Arial, Helvetica, sans-serif;
font-size:19px;
}
h5.logo#lucieaverill {
color:#ffffff !important;
transition: all 0.4s;
}
h5.logo#photography {
color:#ffffff !important;
transition: all 0.6s;
}
h5.logo#lucieaverill.active {
color:#3a3a3a !important;
}
h5.logo#photography.active {
color:#b2b3b3 !important;
transition: all 0.3s;
}
Javascript:
jQuery(document).ready(function($){
$(".header").hover(function(){
$(".header, h5.logo#lucieaverill, h5.logo#photography").addClass("active");
}, function(){ // Callback
$(".header, h5.logo#lucieaverill, h5.logo#photography").removeClass("active");
});
});