Learn how to create a horizontal scrollable menu with CSS.
<div class="scrollmenu">
<a href="#home">Home</a>
<a href="#news">News</a>
<a href="#contact">Contact</a>
<a href="#about">About</a>
...
</div>
The trick to make the navbar scrollable is by using overflow:auto
and white-space: nowrap
:
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;
}
Try it Yourself »
Tip: Go to our CSS Navbar Tutorial to learn more about navigation bars.
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!