Reputation: 103
I'm working on an assignment that has a page with a vertical nav bar in which each of the links are enclosed in a box. The assignment requires that the current link's box be changed to red. I have tried several different methods but none of them seem to work. This is what I have:
/* the styles for the elements */
* {
margin: 0;
padding: 0;
}
html {
background-color: white;
}
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 100%;
width: 850px;
margin: 0 auto;
border: 3px solid #931420;
background-color: #fffded;
}
a:focus, a:hover {
font-style: italic;
}
/* the styles for the header */
header {
padding: 1.5em 0 2em 0;
border-bottom: 3px solid #931420;
background-image: -moz-linear-gradient(
30deg, #f6bb73 0%, #f6bb73 30%, white 50%, #f6bb73 80%, #f6bb73 100%);
background-image: -webkit-linear-gradient(
30deg, #f6bb73 0%, #fffded 30%, white 50%, #fffded 80%, #f6bb73 100%);
background-image: -o-linear-gradient(
30deg, #f6bb73 0%, #fffded 30%, white 50%, #fffded 80%, #f6bb73 100%);
background-image: linear-gradient(
30deg, #f6bb73 0%, #fffded 30%, white 50%, #fffded 80%, #f6bb73 100%);
}
header h2 {
font-size: 175%;
color: #800000;
}
header h3 {
font-size: 130%;
font-style: italic;
}
header img {
float: left;
padding: 0 30px;
}
.shadow {
text-shadow: 2px 2px 2px #800000;
}
/* the styles for the main content */
main {
clear: left;
}
/* the styles for the section */
section {
width: 575px;
float: right;
padding: 0 20px 20px 20px;
}
section h1 {
color: #800000;
font-size: 150%;
padding-top: .5em;
margin: 0;
}
section p {
padding-bottom: .5em;
}
#boldp{
font-weight: bold;
}
#navlist .current{
background-color: #800000;
}
#navlist ul li{
margin: 5px;
background-image: url("../images/right.jpg");
background-repeat: no-repeat;
background-position: 95%;
border: 2px solid black;
border-radius:25px;
padding: 10px;
width: 175px;
height: 35px;
box-shadow: 5px 5px 2px #800000;
}
#navlist ul{
list-style-type: none;
padding: 10px;
}
/* the styles for the article */
article {
padding: .5em 0;
}
article h2 {
font-size: 115%;
padding: 0 0 .25em 0;
}
article img {
float: right;
margin: .5em 0 1em 1em;
border: 1px solid black;
}
/* the styles for the aside */
aside {
width: 215px;
float: right;
padding: 0 0 20px 20px;
}
aside h2 {
color: #800000;
font-size: 130%;
padding: .6em 0 .25em 0;
}
aside h3 {
font-size: 105%;
padding-bottom: .25em;
}
aside img {
padding-bottom: 1em;
}
/* the styles for the footer */
footer {
background-color: #931420;
clear: both;
}
footer p {
text-align: center;
color: white;
padding: 1em 0;
}
<aside>
<h2>Guest speakers</h2>
<nav id ="navlist">
<ul>
<li><h3><a href="c06x_toobin.html">October<br>Jeffrey Toobin</a></h3></li>
<li><h3><a href="#">November<br>Andrew Ross Sorkin</a></h3></li>
<li><h3><a href="#">January<br>Amy Chua</a></h3></li>
<li class ="current"><h3><a href="c07x_sampson.html">February<br>Scott Sampson</a></h3></li>
</ul>
<h3><a href="../index.html">Return to Home page</a></h3>
</nav>
</aside>
Upvotes: 0
Views: 1303
Reputation: 65
Hey if i'm understanding your right I think you just need to add a background for the current class
.current {
background-color:red;
}
Upvotes: 0
Reputation: 53664
#navlist .current
will target the .current
class, and you can apply a background
or whatever it is to that class.
#navlist .current {
background: red;
}
#navlist ul li{
margin: 5px;
background-image: url("../images/right.jpg");
background-repeat: no-repeat;
background-position: 95%;
border: 2px solid black;
border-radius:25px;
padding: 10px;
width: 175px;
height: 35px;
box-shadow: 5px 5px 2px #800000;
}
#navlist ul li.sam {
background-color: #800000;
}
#navlist ul{
list-style-type: none;
padding: 10px;
}
<aside>
<h2>Guest speakers</h2>
<nav id ="navlist">
<ul>
<li><h3><a href="c06x_toobin.html">October<br>Jeffrey Toobin</a></h3></li>
<li><h3><a href="#">November<br>Andrew Ross Sorkin</a></h3></li>
<li><h3><a href="#">January<br>Amy Chua</a></h3></li>
<li class ="current"><h3><a href="c07x_sampson.html">February<br>Scott Sampson</a></h3></li>
</ul>
<h3><a href="../index.html">Return to Home page</a></h3>
</nav>
</aside>
Upvotes: 2