所以我想在我的導航欄中將當前頁面的下劃線和顏色設爲紅色。 紅色框ix我的當前頁面,如果我將頁面更改爲例如:需要紅色/下劃線的工作。我試圖把codepen.io不好使用它,所以沒有工作。 如何使用以下命令創建導航:hover和.active
My code:
HTML
<div class="full-header">
<div class="header">
<div class="nav">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="#">Work</a></li>
<li><a href="#">About Me</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
</div>
<p class="header-text">May I introduce my self?</p>
<hr class="line">
<h2 class="header-text-small">front End Developer</h2>
<div class="button">Aphryv</div>
</div>
CSS
.full-header {
width: 100%;
height: 500px;
background: url(img/header-bg.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.header {
width: 75%;
height: 60px;
margin: 0 auto;
/*background: rgba(0, 0, 0, 0.45);*/
}
.nav {
text-align: right;
}
.nav ul {
}
.nav ul li {
display: inline;
padding: 20px 10px;
line-height: 55px;
}
.nav ul li a {
text-decoration: none;
color: #fff;
font-family: 'Arial', sans-serif;
font-size: 24px;
}
.nav ul li a:hover {
color: red;
}
你的問題還不清楚。把它放到像codepen.io這樣的網站上可能會有幫助,所以你可以輕鬆地分享一個工作(或者說,失敗)的例子。 – thomasfuchs
可能的重複 - http://stackoverflow.com/questions/26088986/highlight-current-link-with-css-or-js –
@Paulie_D我希望我能解決我的問題只是HTML/CSS(沒有學習JavaScript然而) – Aphryv