ich diese Zeilen als Teil meiner Navigation sass haben, hier vereinfacht:Zwei Sass `@ extend`s Konflikt
// These lines (66-72) should generate what I want.
.top-nav .nav {
& > ul {
a {
@extend %section-button;
}
}
}
// These lines (76-82) prevent the previous code from generating what I want.
// Delete it to see things work.
.nav {
& > ul {
a {
@extend %section-button;
}
}
}
Wenn Zeilen 76-82 gelöscht werden, Zeilen 66-72 erzeugen .top-nav .nav > ul a:hover
, die dunkle Anwendung graue Farbe zum Text bei Hover. Wenn die Zeilen 76-82 jedoch bleiben dürfen, wird der Selektor .top-nav .nav > ul a:hover
nicht generiert. Warum ist das?
Das Ändern der Reihenfolge der Auswahlblöcke hilft nicht.
Ich brauche beide Blöcke, weil im .nav
Selektor Block ich Dinge in %section-button
überschreiben, die ich in .top-nav .nav
nicht überschrieben werden soll.
Here's the code in a pen, simplified as much as possible while still demonstrating the problem.
Voll Code:
HTML:
<div class="top-nav">
<nav id="nav" class="nav">
<ul>
<li class="page-link"> <a href="/live">Live</a></li>
</ul>
</nav>
</div>
SCSS:
// Colors
$grey-color-dark: #3f3f3d;
$grey-color-light: lighten($grey-color-dark, 65%);
$blue: #23527c;
$green: #2d5a3a;
// Section Colors
%section-background-color {
background: $grey-color-dark;
}
%section-text-color {
color: $grey-color-dark;
}
// Buttons
%button {
cursor:pointer;
padding:0 1rem;
line-height: 2rem;
height: 2rem;
display:inline-block;
}
%section-button {
@extend %button;
@extend %section-background-color;
color:$grey-color-light;
&:hover, &:focus {
background: $grey-color-light;
@extend %section-text-color;
}
}
// navigation
// These lines (66-72) should generate what I want.
.top-nav .nav {
& > ul {
a {
@extend %section-button;
}
}
}
// These lines (76-82) prevent the previous code from generating what I want. Delete it to see things work.
.nav {
& > ul {
a {
@extend %section-button;
}
}
}
Der Code, der das Problem reproduziert * muss in Ihrer Frage * sein. Links zu externen Websites, die Ihren Code enthalten, sind nicht zulässig. – cimmanon
@cimmanon Ok. Es ist ein bisschen lang, aber ich werde es bearbeiten. –
Wirklich? Sie benötigen * alle * dieses Codes, um das Problem zu reproduzieren? Das ist kein [MCVE]. – cimmanon