I'm trying to make my website accessible via mobile and have arranged it so below a certain size the menu bar at the top turns into a dropdown. Unfortunately it works with hover so when I try to use it on my mobile nothing happens at all. Can anyone suggest how I would alter the code to make it work with touch?
html
<nav id="nav_mobile" role="navigation">
<ul>
<li><a href="#" id="current">Home</a></li>
<li><a href="#">News</a></li>
<li><a href="#">Gallery</a></li>
</ul>
</nav>
CSS
#nav_mobile {
position: relative;
padding-top: 2%;
margin: 0px auto;
}
#nav_mobile ul {
width: 100%;
text-align: center;
position: absolute;
background: #F8F8F8;
min-height: 50px;
background-image: url('../img/Menu_button.png');
background-repeat: no-repeat;
background-position: 50% 0%;
}
#nav_mobile li {
display: none;
margin: 0;
border-bottom: 1px solid #ceced6;
background: #070707;
}
#nav_mobile #current {
display: block;
}
#nav_mobile a {
display: block;
}
#nav_mobile #current a {
background: none;
color: #666;
}
#nav_mobile ul:hover {
background-image: none;
}
#nav_mobile ul:hover li {
display: block;
}
Happy to include jQuery in the code if I need to but I'd like to keep it to just css if I can.
EDIT I've changed the hover to active and added ontouchstart="" to the body tag. The result is the menue now activates but doesn't stay active long enough for you to select a link.