2017-02-16 13 views
0

私は、それぞれのリンクがボックスに囲まれた垂直のナビゲーションバーを持つページを持つ課題に取り組んでいます。この割り当てでは、現在のリンクのボックスを赤に変更する必要があります。私はいくつかの異なる方法を試しましたが、どれもうまくいかないようです。これは私が持っているものです。CSSの現在のページのナビゲーションバーの色の変更

/* the styles for the elements */ 
 
* { 
 
\t margin: 0; 
 
\t padding: 0; 
 
} 
 
html { 
 
\t background-color: white; 
 
} 
 
body { 
 
\t 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 { 
 
\t font-style: italic; 
 
} 
 
/* the styles for the header */ 
 
header { 
 
\t padding: 1.5em 0 2em 0; 
 
\t border-bottom: 3px solid #931420; 
 
\t \t background-image: -moz-linear-gradient(
 
\t  30deg, #f6bb73 0%, #f6bb73 30%, white 50%, #f6bb73 80%, #f6bb73 100%); 
 
\t background-image: -webkit-linear-gradient(
 
\t  30deg, #f6bb73 0%, #fffded 30%, white 50%, #fffded 80%, #f6bb73 100%); 
 
\t background-image: -o-linear-gradient(
 
\t  30deg, #f6bb73 0%, #fffded 30%, white 50%, #fffded 80%, #f6bb73 100%); 
 
\t background-image: linear-gradient(
 
\t  30deg, #f6bb73 0%, #fffded 30%, white 50%, #fffded 80%, #f6bb73 100%); 
 
} 
 
header h2 { 
 
\t font-size: 175%; 
 
\t color: #800000; 
 
} 
 
header h3 { 
 
\t font-size: 130%; 
 
\t font-style: italic; 
 
} 
 
header img { 
 
\t float: left; 
 
\t padding: 0 30px; 
 
} 
 
.shadow { 
 
\t text-shadow: 2px 2px 2px #800000; 
 
} 
 
/* the styles for the main content */ 
 
main { 
 
\t clear: left; 
 
} 
 

 
/* the styles for the section */ 
 
section { 
 
\t width: 575px; 
 
\t float: right; 
 
\t padding: 0 20px 20px 20px; 
 
} 
 
section h1 { 
 
\t color: #800000; 
 
\t font-size: 150%; 
 
\t padding-top: .5em; 
 
\t margin: 0; 
 
} 
 
section p { 
 
\t padding-bottom: .5em; 
 
} 
 

 
#boldp{ 
 
\t font-weight: bold; 
 
} 
 
#navlist .current{ 
 
\t background-color: #800000; 
 
} 
 
#navlist ul li{ 
 
\t margin: 5px; 
 
\t background-image: url("../images/right.jpg"); 
 
\t background-repeat: no-repeat; 
 
\t background-position: 95%; 
 
\t border: 2px solid black; 
 
\t border-radius:25px; 
 
\t padding: 10px; 
 
\t width: 175px; 
 
\t height: 35px; 
 
\t box-shadow: 5px 5px 2px #800000; 
 

 
} 
 

 
#navlist ul{ 
 
\t list-style-type: none; 
 
\t padding: 10px; 
 
} 
 

 
/* the styles for the article */ 
 
article { 
 
\t padding: .5em 0; 
 
} 
 
article h2 { 
 
\t font-size: 115%; 
 
\t padding: 0 0 .25em 0; 
 
} 
 
article img { 
 
\t float: right; 
 
\t margin: .5em 0 1em 1em; 
 
\t border: 1px solid black; 
 
} 
 

 
/* the styles for the aside */ 
 
aside { 
 
\t width: 215px; 
 
\t float: right; 
 
\t padding: 0 0 20px 20px; 
 
} 
 
aside h2 { 
 
\t color: #800000; 
 
\t font-size: 130%; 
 
\t padding: .6em 0 .25em 0; 
 
} 
 

 
aside h3 { 
 
\t font-size: 105%; 
 
\t padding-bottom: .25em; 
 
} 
 
aside img { 
 
\t padding-bottom: 1em; 
 
} 
 

 
/* the styles for the footer */ 
 
footer { 
 
\t background-color: #931420; 
 
\t clear: both; 
 

 
} 
 
footer p { 
 
\t text-align: center; 
 
\t color: white; 
 
\t padding: 1em 0; 
 
}
<aside> 
 
\t \t \t <h2>Guest speakers</h2> 
 
\t \t \t <nav id ="navlist"> 
 
\t \t \t \t <ul> 
 
\t \t \t \t \t <li><h3><a href="c06x_toobin.html">October<br>Jeffrey Toobin</a></h3></li> 
 
\t \t \t \t \t <li><h3><a href="#">November<br>Andrew Ross Sorkin</a></h3></li> \t 
 
\t \t \t \t \t <li><h3><a href="#">January<br>Amy Chua</a></h3></li> \t \t 
 
\t \t \t \t \t <li class ="current"><h3><a href="c07x_sampson.html">February<br>Scott Sampson</a></h3></li> 
 
\t \t \t \t </ul> 
 
\t \t \t <h3><a href="../index.html">Return to Home page</a></h3> 
 
\t \t \t \t 
 
\t \t \t </nav> 
 
\t \t </aside>

答えて

2

#navlist .current.currentクラスを対象とします、そして、あなたはbackgroundを適用するか、または何でもそれはそのクラスにあることができます。

#navlist .current { 
 
    background: red; 
 
} 
 
#navlist ul li{ 
 
\t margin: 5px; 
 
\t background-image: url("../images/right.jpg"); 
 
\t background-repeat: no-repeat; 
 
\t background-position: 95%; 
 
\t border: 2px solid black; 
 
\t border-radius:25px; 
 
\t padding: 10px; 
 
\t width: 175px; 
 
\t height: 35px; 
 
\t box-shadow: 5px 5px 2px #800000; 
 

 
} 
 

 
#navlist ul li.sam { 
 
\t background-color: #800000; 
 
\t } 
 

 
#navlist ul{ 
 
\t list-style-type: none; 
 
\t padding: 10px; 
 
}
<aside> 
 
\t \t \t <h2>Guest speakers</h2> 
 
\t \t \t <nav id ="navlist"> 
 
\t \t \t \t <ul> 
 
\t \t \t \t \t <li><h3><a href="c06x_toobin.html">October<br>Jeffrey Toobin</a></h3></li> 
 
\t \t \t \t \t <li><h3><a href="#">November<br>Andrew Ross Sorkin</a></h3></li> \t 
 
\t \t \t \t \t <li><h3><a href="#">January<br>Amy Chua</a></h3></li> \t \t 
 
\t \t \t \t \t <li class ="current"><h3><a href="c07x_sampson.html">February<br>Scott Sampson</a></h3></li> 
 
\t \t \t \t </ul> 
 
\t \t \t <h3><a href="../index.html">Return to Home page</a></h3> 
 
\t \t \t \t 
 
\t \t \t </nav> 
 
\t \t </aside>

+0

を背景を追加する必要があると思いますこれらの修正プログラムのどちらも機能しないためです。私は元の投稿に残りを追加します –

+0

@KaitJardine背景の変更はあなたの例では動作していますか? –

+0

ここではスニペットから作業していますが、これらの変更を適用してサーバーにアップロードすると、Webページは変更されません。だからこそ、私はそこにCSSをオーバーライドする必要があると思うのですが、なぜCSS全体を含めるように質問を編集したのですか? –

0

私はあなたの権利を理解していた場合ちょっと私はあなただけで私のcssファイルの上書きに何か他のものが存在する必要があり、現在のクラスの

.current { 
    background-color:red; 
} 
関連する問題