How do I make a multi-level dropdown menu work on a touchscreen device using css or javascript? Because when I tested out my website on a touchscreen device I clicked on the dropdown menu (which worked fine), but when I tried to get rid of the dropdown menu I couldn't (unless I reloaded the page). I would like it to have it hover on desktop and not hover on touchscreens. Is that even possible? Here's my html and css text:
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/
normalize.min.css">
<style>
@media (max-width: 640px) {
.main-navigation{
position: absolute;
top: 166px;
left: 173px;
}
ul {
list-style: none;
padding: 0;
margin: 0;
background: #6e151e;
border-radius: 5px;
}
ul li {
display: block;
position: relative;
float: left;
background: #6e151e;
border-radius: 5px;
width: 130px;
}
li ul {
display: none;
position: absolute;
top: 37px;
left: 0px; }
ul li a {
display: block;
padding: 1em;
text-decoration: none;
white-space: nowrap;
color: #fff;
font-family: Helvetica;
font-size: 11px;
padding-top: 12px;
padding-bottom: 12px;
font-weight: 70000px;
border-radius: 5px;
text-align: center;
border-right: none;
}
ul li a:hover {
background: #054075;
transition: .4s ease;
}
li:hover > ul {
display: block;
position: absolute;
transition: .4s ease;
}
li:hover li {
float: none;
transition: .4s ease; }
li:hover a {
background: #6e151e;
transition: .4s ease;
}
li:hover li a:hover {
background: #054075;
transition: .4s ease;
}
@media (max-width: 640px) {
ul ul ul {
border-left: 1px solid #fff;
left: 130px;
top: 0px;
}
}
</style>
</head>
<body>
<ul class="main-navigation">
<li class="Menu"><a href="#">Menu</a>
<ul>
<li><a href="#">Section 1</a>
<ul>
<li><a href="#">Subsection 1</a></li>
<li><a href="#">Subsection 2</a></li>
<li><a href="#">Subsection 3</a></li>
<li><a href="#">Subsection 4</a></li>
</ul>
</li>
<li><a href="#">Section 1</a>
<ul>
<li><a href="#">Subsection 1</a>
</li>
<li><a href="#">Subsection 2</a></li>
<li><a href="#">Subsection 3</a></li>
<li><a href="#">Subsection 4</a></li>
</ul>
</li>
<li><a href="#">Section 3</a>
<ul>
<li><a href="#">Subsection 1</a>
</li>
<li><a href="#">Subsection 2</a></li>
<li><a href="#">Subsection 3</a></li>
<li><a href="#">Subsection 4</a>
</li>
</ul>
</li>
</ul>
</li>
</body>
</html>