I have a pure css pull-down menu that works fine on desktop, iPad and older Android browsers.
But Chrome on Android 5 has a problem: When I select the menu header ("First menu"), then the first item ("Lorem") is always automatically selected. How can I avoid that?
I'm unable to reproduce this problem in other mobile browsers. It also works fine in Chrome on older Android versions.
HTML:
<div class="menuouter"><div onClick=”return true;” class="firstmenu menuinner">First menu<ul>
<li><a class="menuitem " href="#">Lorem</a></li>
<li><a class="menuitem " href="#">Ipsum</a></li>
<li><a class="menuitem " href="#">Lorem</a></li>
<li><a class="menuitem " href="#">Ipsum</a></li>
</ul></div></div>
CSS:
*, *:before, *:after {
box-sizing: border-box;
}
.menuouter {
height: 2.2em;
display: inline-block;
vertical-align: top;
width: 200px;
margin: 0 10px 0 0;
}
.firstmenu {
z-index: 1;
}
.menuinner {
line-height: 2.0em;
margin: 10px;
padding: 0;
border: 2px solid purple;
width: 100%;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
position: relative;
}
.menuinner > ul {
display: none;
width: 100%;
margin: 0;
padding: 0;
}
.menuinner > ul li {
margin: 0;
list-style-type: none;
}
.menuinner > ul li a {
background-color: #ccc;
width: 100%;
display: block;
padding: 5px;
border-bottom: 1px solid red;
}
.menuinner > ul li a:last-child {
border-bottom: none;
}
.menuinner:hover > ul {
padding: 0;
margin: 0;
list-style-type: none;
display: block;
background: #f9f9f9;
border-top: 1px solid purple;
}
.menuinner:hover > ul > li {}
.menuinner:hover > ul > li:hover a {
background: #ccc;
}
.menuinner:hover > ul > li:hover > a {
color: red;
background-color: blue;
}