Reputation: 15
html,body
{
margin: 0;
padding: 0;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
li {
float: right;
}
li a {
display: block;
color: white;
text-align: center;
padding: 28px 32px;
text-decoration: none;
}
li h1
{
position: relative;
color: white;
right: 550px;
}
li a:hover {
background-color: #111;
}
h1
{
color: Green;
font-family: "Alex Brush"; font-size: 26px;
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Marie-Claude</title>
<link rel="stylesheet" type="text/css" href="style.css">
<link href='https://fonts.googleapis.com/css?family=Alex Brush' rel='stylesheet'>
</head>
<body>
<nav>
<ul>
<li><a href="home_fr.html">Francais</a></li>
<li><a href="#">Links</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">About Me</a></li>
<ul>
<li> CV</li>
</ul>
<li><a href="#">Home</a></li>
<li><h1 style="color:#C0C0C0">Marie-Claude Brossard</h1> </li>
</ul>
</nav>
</body>
</html>
As you can see the ul li is making move everything(if you remove it from the code the website looks fine) how can I fix it and get the drop down menu thanks!
Upvotes: 1
Views: 51
Reputation: 87
html,body
{
margin: 0;
padding: 0;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
.dropdown-content {
display: none;
position: absolute;
background-color: red;
min-width: 160px;
padding: 12px 16px;
z-index: 1;
}
li:hover .dropdown-content {
display: block;
}
li {
float: right;
}
li a {
display: block;
color: white;
text-align: center;
padding: 28px 32px;
text-decoration: none;
}
li h1
{
position: relative;
color: white;
right: 550px;
}
li a:hover {
background-color: #111;
}
h1
{
color: Green;
font-family: "Alex Brush"; font-size: 26px;
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Marie-Claude</title>
<link rel="stylesheet" type="text/css" href="style.css">
<link href='https://fonts.googleapis.com/css?family=Alex Brush' rel='stylesheet'>
</head>
<body>
<nav>
<ul class ="dropdown">
<li><a href="home_fr.html">Francais</a></li>
<li><a href="#">Links</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">About Me</a>
<div class="dropdown-content">
<ul><li>Something</li></ul>
</div>
</li>
<li><a href="#">Home</a></li>
<li><h1 style="color:#C0C0C0">Marie-Claude Brossard</h1> </li>
</ul>
</nav>
</body>
</html>
Upvotes: 1
Reputation: 185
How about this?
If you want a sub-menu inside a menu, ul tag must be inside the li tag itself.
<ul>
<li><a href="home_fr.html">Francais</a></li>
<li><a href="#">Links</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">About Me</a>
<ul>
<li> CV</li>
</ul></li>
<li><a href="#">Home</a></li>
<li><h1 style="color:#C0C0C0">Marie-Claude Brossard</h1> </li>
</ul>
Upvotes: 0