Reputation: 43
First off, I'm really new to this so sorry if I sound dumb ;_;. Now, I'm trying to make a background color on my list items. Like this site has, black bar with the logo, search bar etc.. I tried wrapping divs everywhere but nothing seems to work.
HTML
<nav class="nav-menu">
<div class="container">
<ul>
<li>About Us</li>
<li>Staff</li>
<li>Schedule</li>
<li>Home</li>
</ul>
</div>
</nav>
CSS
.nav-menu ul {
margin-right: 50px;
}
.nav-menu li {
list-style: none;
display: inline;
margin-left: 30px;
float: right;
color: red;
}
.container {
color: black;
}
Upvotes: 0
Views: 56
Reputation: 26
You could add a clearfix after your floating element.
html: put a
<div class="clear"></div>
after your <ul></ul>
related css:
.clear {
clear: both;
}
and you would need to change color: black;
to background-color: black;
;-)
see: http://jsfiddle.net/Hm4KJ/4/
Upvotes: 0
Reputation: 1219
if you only want a background color in each list item you can use this one:
.nav-menu li {
list-style: none;
display: inline;
margin-left: 30px;
float: right;
color: red;
background:#000000;
display:inline-block;
padding:5px 10px;
}
Upvotes: 0
Reputation: 44581
Set overflow
to auto
to display everything in the .content
div (now everything is hidden
because you use float
property)
.container {
background: black;
overflow:auto;
}
I guess it is a typo, anyway , you should set background
property instead of color
to set background color.
Upvotes: 2