I am working on a small website for my teacher and I am supposed to do a navigation menu with submenu (I am using :hover). That website will be used on computer and on tablets or Ipad. My menu is finished but on tablets I encounter the following issue : my submenu shows well but it does not hide when I touch elsewhere on the screen (except on the logo - do not know why). An other student told me he found a solution but when he touched one of the links in the submenu, the submenu hide and this is not the result I want. Our teacher told us we must absolutely not use something else than HTML and CSS (No JS, no Jquery).
Here is my code :
body > header > nav {
min-width: 768px;
margin: 0 auto;
padding-top: 20px;
font-size: 1.5em;
text-align: center;
}
nav > ul ul {
position: absolute;
left: -999em;
text-align: left;
}
nav li {
width: 150px;
}
nav > ul > li {
display: inline-block;
}
nav a {
display: block;
text-decoration: none;
}
nav > ul > li > a {
padding: 10px 0;
color: #44546A;
}
nav > ul ul li {
background-color: #333F50;
list-style-type: none;
}
nav > ul ul li a {
padding: 10px 0 10px 30px;
}
nav > ul ul li a {
color: #FAFAFA;
font-size: 0.9em;
}
nav > ul ul li:hover {
background-color: #51647f;
}
nav > ul li:hover ul {
left: auto;
}
<html>
<body>
<header>
<img src="img/logo_def_vect.svg" alt="Logo"/>
<nav>
<ul>
<li>
<a href="#">Menu1</a>
<ul>
<li>
<a href="#">SubMenu1.1</a>
</li>
</ul>
</li>
<li><a href="#">Menu2</a>
<ul>
<li>
<a href="#">SubMenu2.2</a>
</li>
<li>
<a href="#">SubMenu2.3</a>
</li>
</ul>
</li>
</ul>
</nav>
</header>
</body>
</html>