gpt4 book ai didi

html - 页面底部的水平滚动导航栏

转载 作者:行者123 更新时间:2023-12-04 02:29:32 25 4
gpt4 key购买 nike

我试图在页面底部制作一个水平滚动的导航栏,但是当我放置 position: fixed; 时,它使导航栏不可滚动。

div.scrollmenu {
background-color: #333;
overflow: auto;
white-space: nowrap;
}

div.scrollmenu a {
display: inline-block;
color: white;
text-align: center;
padding: 14px;
text-decoration: none;
}

div.scrollmenu a:hover {
background-color: #777;
}
<div class="scrollmenu">
<a href="#home">Home</a>
<a href="#news">News</a>
<a href="#contact">Contact</a>
<a href="#about">About</a>
<a href="#support">Support</a>
<a href="#blog">Blog</a>
<a href="#tools">Tools</a>
<a href="#base">Base</a>
<a href="#custom">Custom</a>
<a href="#more">More</a>
<a href="#logo">Logo</a>
<a href="#friends">Friends</a>
<a href="#partners">Partners</a>
<a href="#people">People</a>
<a href="#work">Work</a>
</div>

<h2>Horizontal Scrollable Menu</h2>

这里是 fiddle :https://jsfiddle.net/J1aaa/rco4kz70/3/

最佳答案

你所要做的就是“width”和“overflow-x”滚动形状

div.scrollmenu width: 100%; and overflow-x: auto; 

div.scrollmenu {
width: 100%;
background-color: #333;
overflow-x: auto;
white-space: nowrap;
position: fixed;
bottom: 0;
display: block;
}

div.scrollmenu a {
display: inline-block;
color: white;
text-align: center;
padding: 14px;
text-decoration: none;
}

div.scrollmenu a:hover {
background-color: #777;
}
<div class="scrollmenu">
<a href="#home">Home</a>
<a href="#news">News</a>
<a href="#contact">Contact</a>
<a href="#about">About</a>
<a href="#support">Support</a>
<a href="#blog">Blog</a>
<a href="#tools">Tools</a>
<a href="#base">Base</a>
<a href="#custom">Custom</a>
<a href="#more">More</a>
<a href="#logo">Logo</a>
<a href="#friends">Friends</a>
<a href="#partners">Partners</a>
<a href="#people">People</a>
<a href="#work">Work</a>
</div>

<h2>Horizontal Scrollable Menu</h2>

关于html - 页面底部的水平滚动导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65228424/

25 4 0