我有一個導航欄,其中按鈕具有懸停狀態,但也需要在其各自的頁面上處於「活動」狀態。由於此導航欄是包含的一部分,因此我決定通過body標籤上的類來執行活動狀態,如.dashboard .dashboard-button
。所以我有這個懸停。Sass多狀態導航欄問題
我試圖找出最簡單的方法來做到這一點與Sass/Compass。我創建了幾個混入的:
@mixin nav-button-on($icon) {
background-color: #2f3684; // Old browsers
@include filter-gradient($offwhite, #E5E5E5, vertical); // IE6-9
@include background-image(url('../images/'+$icon+'-on.png'),linear-gradient(top, $offwhite 0%, #E5E5E5 100%));
border-bottom: $borderbottom solid #F31A35;
a { color: $red;}
}
@mixin nav-button($icon){
background-color: #fff; // Old browsers
@include filter-gradient(#fff, #fff, vertical); // IE6-9
@include background-image(url('../images/'+$icon+'.png'),linear-gradient(top, #fff 0%, #fff 100%));
}
當按鈕被定義
然後在李,我有
li {
&.dashboard {
@include nav-button('dashboard');
}
.dashboard &.dashboard {
@include nav-button-on('dashboard');
&:hover {
@include nav-button-on('dashboard');
}
}
}
HTML:
<body class="dashboard">
<div id="nav">
<ul>
<li class="first dashboard"><a href="/index.php">Dashboard</a></li>
<li class="challenges"><a href="/challenges.php">Challenges & Teams</a></li>
<li class="goals"><a href="/goals.php">Goals</a></li>
<li class="activity"><a href="/my-activity.php">My Activity</a></li>
<li class="destinations"><a href="/destinations.php">Destinations</a></li>
<li class="fitness last"><a href="/fitness-resources.php">Fitness Resources</a></li>
</ul>
</div>
這似乎有點令人費解,我想知道是否有人有任何建議來簡化這一切。
注:我不得不添加白色到白色的漸變,因爲當將鼠標懸停在具有漸變懸停狀態的純色背景上時會導致閃光。
我們可以看到你的html標記嗎? – bookcasey
加入問題 – Steve
如何在評論中獲得格式化的縮進代碼? – Steve