Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

HTML & CSS Help with Multilevel/Sublevels on navigation bar

amuses

New Coder
Hi all, iam really new in html and css and in the basic stage, I've found a code online which I have edited to my liking. i would like to add multilevel/sublevels to the nav bar when hovered on. i have attached the html and css . any help or guidance on this would be highly appreciated.

thanks in advance

HTML:
<html>
    <head>
 


        <title> CHAMPION FOR CHANGE </title>
        <link rel="stylesheet" type="text/css" href="css/championsindex.css"
        
        
    </head>
    <header>
        <div class="container">
            <img src="LOGO.png" alt="logo" class="logo">
          <h1 class="logo"></h1>
    
          <nav>
            <ul>
                <li><a href="#">Home</a></li>
                <li><a href="#">who we are</a></li>
                <li><a href="#">What We Do</a></li>
                <li><a href="#">Resources</a></li>
                <li><a href="#">Blog</a></li>
                <li><a href="#">contact us</a></li>         
            </ul>
          </nav>
        </div>
      </header>
</html>

CSS:
@import url('https://fonts.googleapis.com/css?family=Work+Sans:400,600');
body {
    margin: 0;
    background: #222;
    font-family: 'Work Sans', sans-serif;
    font-weight: 800;
}

.container {
    width: 80%;
    margin: 0 auto;
}

header {
  background: #55d6aa;
}

header::after {
  content: '';
  display: table;
  clear: both;
}

.logo {
  float: left;
  padding: 10px 0;
}

nav {
  float: right;
}

nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

nav li {
  display: inline-block;
  margin-left: 70px;
  padding-top: 23px;

  position: relative;
}

nav a {
  color: #444;
  text-decoration: none;
  text-transform: uppercase;
  font-size: 14px;
}

nav a:hover {
  color: #000;
}

nav a::before {
  content: '';
  display: block;
  height: 5px;
  background-color: #444;

  position: absolute;
  top: 0;
  width: 0%;

  transition: all ease-in-out 250ms;
}

nav a:hover::before {
  width: 100%;
}
 
This needs work. It's just here to show you some of the styling that needs to be done and how to make a sub menu
Please note where the head end and body begins - missing from yours
Code:
<style>
@import url('https://fonts.googleapis.com/css?family=Work+Sans:400,600');
body {
    margin: 0;
    background: #222;
    font-family: 'Work Sans', sans-serif;
    font-weight: 800;
}
.container {
    width: 80%;
    margin: 0 auto;
}
header {
    background: #55d6aa;
}
header::after {
    content: '';
    display: table;
    clear: both;
}
.logo {
    float: left;
    padding: 10px 0;
}
nav {
    float: right;
}
nav ul {
    margin: 0;
    padding: 0;
    list-style: none;
}
nav li {
    display: inline-block;
    margin-left: 70px;
    padding-top: 23px;
    position: relative;
}
nav a {
    color: #444;
    text-decoration: none;
    text-transform: uppercase;
    font-size: 14px;
}
nav a:hover {
    color: #000;
}
nav a::before {
    content: '';
    display: block;
    height: 5px;
    background-color: #444;
    position: absolute;
    top: 0;
    width: 0%;
    transition: all ease-in-out 250ms;
}
nav a:hover::before {
    width: 100%;
}
/* Here down added for sub menu */
#sub{display: none;}
#main:hover #sub{display: block;}
#sub {
    display: none;
    position: absolute;
    left: 10px;
    background-color: red;
    width: 100%;
    z-index: 1;
}
#sub a {
    margin-left:10px;
    color: white;
    text-decoration: none;
}
#sub a:hover {
    color: black;
   }
</style>
</head>

<body>
<header>
    <div class="container">
        <img src="LOGO.png" alt="logo" class="logo">
        <h1 class="logo"></h1>
        <nav>
        <ul>
            <li><a href="#">Home</a></li>
            <li id="main"><a href="#">who we are</a>
                <ul id="sub">
                    <a href="#">Kill em</a>
                    <a href="#">Clean em</a>
                    <a href="#">Skin em</a>
                    <a href="#">Sell em</a>
                </ul>
            </li>
            <li><a href="#">Resources</a></li>
            <li><a href="#">Blog</a></li>
            <li><a href="#">contact us</a></li>         
        </ul>
        </nav>
    </div>
</header>
 

Buy us a coffee!

Back
Top Bottom