I'm really stuck and although i found some tips and tricks (javascript) i don't get it t work. Problem is i have a great looking and functioning collapseble menu but when i click on the main links (Nederland, Belgie, Frankrijk, Zoeken) the page scrolls to top.
I rather not fix this with javascript onclick because i would like to keep the "href" links intact because of SEO purposes.
I hope you guys and girls can help me out, would be much appreciated!
<ul class="mainMenuA">
<li class="item" id="nl">
<a href="#nl" class="btnA"><span class="flag flag-nl"></span> Nederland</a>
<div class="subMenu">
<a href="/amsterdam">Amsterdam</a>
<a href="/arnhem">Arnhem</a>
<a href="/utrecht">Utrecht</a>
</div>
</li>
<li class="item" id="be">
<a href="#be" class="btnA"><span class="flag flag-be"></span> België</a>
<div class="subMenu">
<a href="/item1">item-1</a>
<a href="/item2">item-2</a>
</div>
</li>
<li class="item" id="fr">
<a href="#fr" class="btnA"><span class="flag flag-fr"></span> Frankrijk</a>
<div class="subMenu">
<a href="/item1">item-1</a>
</div>
</li>
<li class="item">
<a href="#search" class="btnA"><i class="fas fa-search"></i>Zoeken</a>
</li>
</ul>
<style>
a:hover {
color:white;
font-weight:bold;
}
.mainMenuA{
width: 250px;
display: block;
border-radius: 10px;
overflow: hidden;
list-style: none;
font-weight:normal;
}
.item{
border-top: 1px solid #ef584a;
overflow: hidden;
}
.btnA{
display: block;
padding: 15px 20px;
background-color: #ff4a52;
color: #fff;
position: relative;
}
.btnA:before{
content: '';
position: absolute;
width: 0;
height: 0;
border-left: 8px solid transparent;
border-right:8px solid transparent;
border-top:10px solid #ff4a52;
right: 15px;
bottom: -10px;
z-index: 9;
}
.btnA i {
margin-right: 10px;
}
.subMenu{
background: #273057;
overflow: hidden;
transition: max-height 0.7s;
max-height: 0;
}
.subMenu a{
display: block;
padding: 15px 20px;
color: #fff;
font-size: 14px;
border-bottom: 1px solid #394c7f;
position: relative;
}
.subMenu a:before{
content: '';
opacity: 0;
transition: opacity 0.3s;
}
.subMenu a:hover:before{
content: '';
position: absolute;
height: 0;
width: 6px;
left: 0;
top:0;
opacity: 1;
/* background-color: #d8d824; */
border-top: 24px solid transparent;
border-left: 11px solid #ffffff;
border-bottom: 24px solid transparent;
}
.subMenu a:after{
content: '';
opacity: 0;
transition: opacity 0.3s;
}
.subMenu a:hover:after{
content: '';
position: absolute;
height: 0;
width: 6px;
right: 0px;
top:0;
opacity: 1;
/* background-color: #d8d824; */
border-top: 24px solid transparent;
border-right: 11px solid #ffffff;
border-bottom: 24px solid transparent;
}
.subMenu a:hover{
background: #273057;
background: -moz-linear-gradient(top, #273057 0%, #273057 50%, #394c7f 51%, #394c7f 100%);
background: -webkit-linear-gradient(top, #273057 0%,#273057 50%,#394c7f 51%,#394c7f 100%);
background: linear-gradient(to bottom, #273057 0%,#273057 50%,#394c7f 51%,#394c7f 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#273057', endColorstr='#394c7f',GradientType=0 );
transition: all 0.3s;
border-bottom: 1px solid #394c7f;
}
.subMenu a:last-child{
border:none;
}
.item:target .subMenu{
max-height: 1000em;
}
</style>