主頁
CSS
CSS 導航欄
垂直導航欄
Tryit: 垂直導航欄,帶邊框和居中文字
執行 ❯
建立您
自己的
網站
×
更改方向
儲存程式碼
更改主題,深色/淺色
前往 Spaces
<!DOCTYPE html> <html> <head> <style> ul { list-style-type: none; margin: 0; padding: 0; width: 200px; background-color: #f1f1f1; border: 1px solid #555; } li a { display: block; color: #000; padding: 8px 16px; text-decoration: none; } li { text-align: center; border-bottom: 1px solid #555; } li:last-child { border-bottom: none; } li a.active { background-color: #04AA6D; color: white; } li a:hover:not(.active) { background-color: #555; color: white; } </style> </head> <body> <h2>Vertical Navigation Bar</h2> <p>In this example, we center the navigation links and add a border to the navigation bar.</p> <ul> <li><a class="active" href="#home">Home</a></li> <li><a href="#news">News</a></li> <li><a href="#contact">Contact</a></li> <li><a href="#about">About</a></li> </ul> </body> </html>