页面重定向导致选择正确的活动页面时出现问题

问题描述 投票:0回答:1

我正在使用Squarespace,将页面“ danieconz.com/about”设置为我的主页,因此,它被重定向到“ danielconz.com”。

我已经在页脚和一些CSS代码中创建了指向页面的链接。我的问题是,当我进入“ danielconz.com”时,这些链接会全部选中。但是,仅应选择“关于”链接。

这是我正在使用的CSS:

    @media all and (max-width:750px) {
#footer h1 {
    width: 120px;
    margin: 0 auto;
    padding-bottom: 0px;
    line-height: 70px!important;
 }
#footer h1 .active-link {
  border-top: 2px solid #1a1611;
}
#footer h1 a:hover {
  border-top: 2px solid #1a1611;
}
}

@media all and (min-width:750px) {
#footer h1 a:hover {
  border-top: 2px solid #1a1611;
  padding: 0px !important;
}

#footer h1 .active-link  {
  border-top: 2px solid #1a1611;
  padding: 0px !important;
}
}

并在台式机和移动设备上跟踪该问题的几个图像。有人可以帮我吗?预先感谢。

desktopmobile

html css squarespace
1个回答
0
投票

您有一个JavaScript将链接活动类添加到页脚中的链接。

您可以做的一件事就是将功能更改为此,请检查一下:

$(function() {
if(location.pathname.split("/")[1]==""){
    $('footer h1 a').removeClass('active-link');
    $('footer h1 a[href^="/about"]').addClass('active-link');
}else{
    $('footer h1 a[href^="/' + location.pathname.split("/")[1] + '"]').addClass('active-link');
}
$('body').addClass('enter');//This part is the same
});
© www.soinside.com 2019 - 2024. All rights reserved.