我想将我的导航从透明背景更改为白色背景。导航应该缩小尺寸并且徽标应该消失。
它应该与此页面上的完全相同:https : //www.praxis-loeber.de
我已经为它编写了 jquery 代码,但不幸的是它仍然不起作用。
如果有人能告诉我代码中的错误在哪里,我会很高兴。
这是我的代码:
$(window).scroll(function() {
var scroll = $(window).scrollTop();
if (scroll > 10) {
$(".navigation").addClass("transparent");
$(".hr").hide();
$(".header-logo-container").hide();
$("a").css("color", "black");
} else {
$(".navigation").removeClass("transparent");
$(".hr").show();
$(".header-logo-container").show();
$("a").css("color", "white")
}
});Run Code Online (Sandbox Code Playgroud)
.header {
height: 820px;
background-image: url("../img/beispiel.png");
background-size: cover;
}
.header-unterseite {
height: 500px;
background-image: url("../img/beispiel.png");
background-size: cover;
}
.navigation {
position: sticky;
top: 0px;
}
.navigation.transparent {
background-color: white;
}
.header-logo-container {
text-align: center;
@media(max-width: 950px) {
display: none;
}
}
.header-logo {
width: …Run Code Online (Sandbox Code Playgroud)