TokTok123
TokTok123

Reputation: 771

Navigation bar background not showing

I'm building a really basic navigation bar but I can't figure out why the background colour of the navigation bar as set in my stylesheet (which I beleive I've set correctly) isn't showing.

Below is what I'm looking to achieve with the background:

desired outcome

And here's what I've achieved so far

current outcome

Here's my CSS code:

    @import url(http://fonts.googleapis.com/css?family=Open+Sans:700);

html {height: 100%; width: 100%;}

body {
    height: 100%; 
    width: 100%;
    margin: 0; 
    padding: 0; 
    border: 0;
    font-family: "Helvetica", Arial, sans-serif;
    font-size: 14px; 
    line-height: 15px;
}

/* Top bar*/
.topbar {
  background: #F96E5B;
  height: 50px;
  width: auto;
}

/* Logo img button*/
#topbar img {
    position: absolute;
    float: left;
    width: 125px;
    height: 25px;
    padding-left: 12px;
    padding-top: 12px;
}

/* ul */
#topbar ul {
    float: right;
    list-style: none;
    margin: 0;
    padding: 0;
    line-height: 1;
    display: block;
    zoom: 1;
}

/* li */
#topbar ul li {
    display: inline-block;
    padding: 0;
    margin: 0;
}

/* Insert a gap after every <ul> element */
#topbar ul:after {
  content: " ";
  display: block;
  font-size: 0;
  height: 0;
  clear: both;
  visibility: hidden;
}

/* li */
#topbar ul li a {
  color: #000000;
  text-decoration: none;
  display: block;
  padding: 15px 25px;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 14px;
  position: relative;
  -webkit-transition: color .25s;
  -moz-transition: color .25s;
  -ms-transition: color .25s;
  -o-transition: color .25s;
  transition: color .25s;  
}

#topbar ul li a:hover {
  color: #FFCC00;
}

/* bullet point after the menu name */
#topbar ul li a:after {
  content: "";
  display: block;
  position: absolute;
  right: -3px;
  top: 19px;
  height: 6px;
  width: 6px;
  background: #FF0000;
  opacity: .5;
}

#topbar ul li a:before {
  content: "";
  display: block;
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 0;
  background: #00FF00;
  -webkit-transition: width .25s;
  -moz-transition: width .25s;
  -ms-transition: width .25s;
  -o-transition: width .25s;
  transition: width .25s;
}

#topbar ul li.last > a:after,
#topbar ul li:last-child > a:after {
  display: none;
}

#topbar ul li.active a {
  color: #FFDD00;
}

#topbar ul li.active a:before {
  width: 100%;
}

#topbar.align-right li.last > a:after,
#topbar.align-right li:last-child > a:after {
  display: block;
}
#topbar.align-right li:first-child a:after {
  display: none;
}

Here's my HTML code:

    <!DOCTYPE html>
<html>

    <head>
       <meta charset='utf-8'>
       <meta http-equiv="X-UA-Compatible" content="IE=edge">
       <meta name="viewport" content="width=device-width, initial-scale=1">
       <link rel="stylesheet" href="stylesheets/public.css">
       <title>Welcome to Swim-mates</title>    
    </head>

<body>
    <div id="topbar">
        <img src="images/logoimg.png">
        <!-- <button class="login" type="submit">Log In</button> -->

        <ul>
           <li class='active'><a href='#'><span>Home</span></a></li>
           <li><a href='#'><span>Products</span></a></li>
           <li><a href='#'><span>Company</span></a></li>
           <li class='last'><a href='#'><span>Contact</span></a></li>
        </ul>       
    </div>

    <div class="main">

        <div id="welcome_message">

        </div>

        <div id="slideshow">

        </div>

        <div id="signup">

        </div>              

    </div>
</body>

</html>

I'm sure its a small oversight on my part. Thanks for any suggestions.

Upvotes: 0

Views: 145

Answers (2)

Alexis Peters
Alexis Peters

Reputation: 1631

.topbar {
  background: #F96E5B;
  height: 50px;
  width: auto;
}

needs to be

#topbar {
  background: #F96E5B;
  height: 50px;
  width: auto;
}

because you declared "topbar" as id

Upvotes: 2

akash
akash

Reputation: 2157

You are using ID in HTML so use "#" for topbar

Try this:

/* Top bar*/
#topbar {
  background: #F96E5B;
  height: 50px;
  width: auto;
}

Upvotes: 4

Related Questions