菜单位置粘滞不起作用(引导程序)



我已经尝试了所有的方法,但我的粘性位置不起作用,没有溢出的父元素,我放了顶部:30%

#games-container #pills-tab {
-webkit-backdrop-filter: blur( 5px );
backdrop-filter: blur( 5px );
background: rgba( 30, 30, 30, 0.5 );
border-radius: 10rem;
border: 1px solid rgba( 255, 255, 255, 0.18 );
height: fit-content;
padding: 1rem;
top: 30%;
width: 60%;
}
#games-container .nav-item {
padding: .5rem;
}
#games-container .nav-item .nav-link.active {
background-color: #FFC85D;
color: #1E1E1E;
}
#games-container .nav-item .nav-link {
background-color: #545454;
border-radius: 10rem;
color: #FFFFFF;
transition: .5s;
}
#games-container .nav-item .nav-link:hover {
color: #1E1E1E;
}
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/js/bootstrap.bundle.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet"/>
<ul class="nav nav-pills d-flex justify-content-around position-sticky mt-5 mb-5" id="pills-tab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="pills-destaques-tab" data-bs-toggle="pill" data-bs-target="#pills-destaques" type="button" role="tab" aria-controls="pills-destaques" aria-selected="true">Destaques</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="pills-aventura-tab" data-bs-toggle="pill" data-bs-target="#pills-aventura" type="button" role="tab" aria-controls="pills-aventura" aria-selected="false">Aventura</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="pills-acao-tab" data-bs-toggle="pill" data-bs-target="#pills-acao" type="button" role="tab" aria-controls="pills-acao" aria-selected="false">Ação</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="pills-coop-tab" data-bs-toggle="pill" data-bs-target="#pills-coop" type="button" role="tab" aria-controls="pills-coop" aria-selected="false">Cooperativo</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="pills-fps-tab" data-bs-toggle="pill" data-bs-target="#pills-fps" type="button" role="tab" aria-controls="pills-fps" aria-selected="false">FPS</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="pills-luta-tab" data-bs-toggle="pill" data-bs-target="#pills-luta" type="button" role="tab" aria-controls="pills-luta" aria-selected="false">Luta</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="pills-rpg-tab" data-bs-toggle="pill" data-bs-target="#pills-rpg" type="button" role="tab" aria-controls="pills-rpg" aria-selected="false">RPG</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="pills-terror-tab" data-bs-toggle="pill" data-bs-target="#pills-terror" type="button" role="tab" aria-controls="pills-terror" aria-selected="false">Terror</button>
</li>
</ul>
<div>
<h1>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nam asperiores eum, sed odit minus facilis tenetur, fugit non quas nisi fugiat et? Hic in facilis distinctio saepe modi. Nisi, corporis!</h1>
</div>
<div>
<h1>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nam asperiores eum, sed odit minus facilis tenetur, fugit non quas nisi fugiat et? Hic in facilis distinctio saepe modi. Nisi, corporis!</h1>
</div>
<div>
<h1>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nam asperiores eum, sed odit minus facilis tenetur, fugit non quas nisi fugiat et? Hic in facilis distinctio saepe modi. Nisi, corporis!</h1>
</div>
<div>
<h1>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nam asperiores eum, sed odit minus facilis tenetur, fugit non quas nisi fugiat et? Hic in facilis distinctio saepe modi. Nisi, corporis!</h1>
</div>  <div>
<h1>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nam asperiores eum, sed odit minus facilis tenetur, fugit non quas nisi fugiat et? Hic in facilis distinctio saepe modi. Nisi, corporis!</h1>
</div>
<div>
<h1>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nam asperiores eum, sed odit minus facilis tenetur, fugit non quas nisi fugiat et? Hic in facilis distinctio saepe modi. Nisi, corporis!</h1>
</div>
<div>
<h1>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nam asperiores eum, sed odit minus facilis tenetur, fugit non quas nisi fugiat et? Hic in facilis distinctio saepe modi. Nisi, corporis!</h1>
</div>
<div>
<h1>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nam asperiores eum, sed odit minus facilis tenetur, fugit non quas nisi fugiat et? Hic in facilis distinctio saepe modi. Nisi, corporis!</h1>
</div>
<div>
<h1>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nam asperiores eum, sed odit minus facilis tenetur, fugit non quas nisi fugiat et? Hic in facilis distinctio saepe modi. Nisi, corporis!</h1>
</div>
<div>
<h1>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nam asperiores eum, sed odit minus facilis tenetur, fugit non quas nisi fugiat et? Hic in facilis distinctio saepe modi. Nisi, corporis!</h1>
</div>
<div>
<h1>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nam asperiores eum, sed odit minus facilis tenetur, fugit non quas nisi fugiat et? Hic in facilis distinctio saepe modi. Nisi, corporis!</h1>
</div>
<div>
<h1>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nam asperiores eum, sed odit minus facilis tenetur, fugit non quas nisi fugiat et? Hic in facilis distinctio saepe modi. Nisi, corporis!</h1>
</div>
<div>
<h1>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nam asperiores eum, sed odit minus facilis tenetur, fugit non quas nisi fugiat et? Hic in facilis distinctio saepe modi. Nisi, corporis!</h1>
</div>

如果你想让你的nav坚持下去,你可以使用css将{top:0}代码添加到你的.nav中。。。在你的CSS文件中添加此代码,它应该可以解决你的问题:

.nav{top: 0;}

相关内容

  • 没有找到相关文章

最新更新