In this below HTML/CSS program i have used ul li to display items side by side. However when the drop down menu occurs, the items are displayed one below another and not side by side. Why is this happening?
To be more clear Home Promotions About Contact Signin are displayed next to each other. This is because they fall under ul/li. But when I hover around Promotions why Twitter Facebook Instagram are displayed below each other, and not next to each other. They also fall under ul li css styling right and hence the question.
Sincerely,
Sudarsan.D
body {
color: white;
background-size: cover;
font-family: Arial;
}
ul {
margin: 0px;
padding: 0px;
list-style: none;
}
ul li {
width: 220px;
height: 80px;
background-color: black;
opacity: .8;
line-height: 40px;
text-align: center;
font-size: 20px;
float: left;
}
ul li a {
text-decoration: none;
}
ul li a:hover {
background-color: green;
}
ul li ul li {
display: none;
}
ul li:hover ul li {
display: block;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="styles.css" rel="stylesheet">
<link href="index.css" rel="stylesheet">
<title>Why</title>
</head>
<body>
<ul>
<li><a>Home</a></li>
<li><a>Promotions</a>
<ul>
<li><a>Twitter</a></li>
<li><a>Facebook</a></li>
<li><a>Instragram</a></li>
</ul>
</li>
<li><a>About</a>
<ul>
<li><a>Shop</a></li>
<li><a>Founders</a></li>
<li><a>Feedback</a></li>
</ul>
</li>
<li><a>Contact</a>
<ul>
<li><a>Map</a></li>
<li><a>Directions</a></li>
</ul>
</li>
<li><a>Sign in</a> </li>
</ul>
</body>
</html>