Why does my unordered list show up below the division element that I want to style?
* {
padding: 0;
margin: 0
}
#nav {
width: 100%;
background-color: #00ff00;
}
#cog {
padding-left: 100px;
}
li {
color: black;
float: left;
padding-left: 100px;
list-style-type: none;
}
ul {
color: black;
float: right;
}
a {
color: black;
text-decoration: none;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Karuki Wireframe Project (p2)</title>
<link rel="stylesheet" href="css/font-awesome.min.css">
<link rel="stylesheet" href="regular.css">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<div id="nav">
<nav>
<ul>
<i class="fa fa-cog" aria-hidden="true" id="cog"></i>
<li><a href="#">Username</a></li>
<li><a href="#">Home</a></li>
<li><a href="#">Privacy</a></li>
<li><a href="#">Deadline</a></li>
</nav>
</div>
</body>
<script>
var windowSize = 0;
window.onresize = function() {
windowSize = window.innerWidth
console.log(windowSize);
if (windowSize < 600) {
alert("you are mobile");
}
}
</script>
</html>
I do not see the green background-color behind the unordered list. Why is this?
The only solution I found was to put a height on the #nav division, but when I did that it looked as though the two elements were not connected to each other at all. It was as though the ul was not even written into the inside of the #nav division.