嘿,我正在學習bootstrap/CSS,同時我設計了一門課程的網站。Bootstrap在標頭中創建活動按鈕鏈接
現在,我有我的頭這是罰款。有一些按鈕,其中有一個標籤可以覆蓋所有這些按鈕,並且這些按鈕都位於一些div和容器內。
我想要它,所以當我點擊主頁或任何按鈕被激活時,我可以改變它的顏色,例如當我在網站的那部分時灰色。我試過&:活躍,但它不這樣工作。
對不起,如果它之前我已經搜查了很多,並不知道如何找到它。還檢查了bootstrap文檔。
繼承人是我的代碼
CSS
header{
text-align: center;
padding-bottom: 0em;
}
.navbar-inverse{
background: gray;
}
.btn {
border-style: dotted;
border-color: gray;
line-height: 5em;
width: 8em;
a{
color: white;
font-size: 1.5em;
font-weight: bold;
display:block;
width: 100%;
height: 100%;
&:active{
background-color: gray;
}
&:hover{
text-decoration: none;
background-color: navy;
}
}
}
.btn-lg{
background: black;
height: 90px;
padding: 0px 0px 0px 0px;
}
HTML HEADER
<header class="navbar navbar-fixed-top navbar-inverse">
<div class="container">
<button type="button "class="btn btn-lg"><%= link_to current_user.name, current_user %></button>
<button type="button" class="btn btn-lg"><%= link_to "Log Out", root_path %></button>
<button type="button" class="btn btn-lg"><%= link_to "New Event", new_event_path %></button>
<button type="button" class="btn btn-lg"><%= link_to "All Events", events_path %></button>
</div>
</header>
這可能是它。我已經實現了它,但我不知道應該在哪裏添加.active類。我是否將它添加到按鈕,以.btn類,鏈接? –
是的,你可以做到。你也可以保持原樣。 jquery選擇器中的按鈕指向按鈕元素。 – claudios
或者嘗試將您的按鈕替換爲錨標籤,然後將jquery選擇器替換爲'a'。 – claudios