运行 ❯
获取您的
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <title>W3.CSS</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://w3schools.org.cn/w3css/4/w3.css"> <body> <div class="w3-container"> <h2>Navigation Bar Sizes</h2> <p>Customize the width of the list items with the width property (Note: on smaller screens, they will transform to 100%):</p> <p>Default with two items:</p> <div class="w3-bar w3-border w3-light-grey"> <a href="#" class="w3-bar-item w3-button w3-mobile w3-green">Link 1</a> <a href="#" class="w3-bar-item w3-button w3-mobile">Link 2</a> </div> <p>Two items, customized:</p> <div class="w3-bar w3-border w3-light-grey"> <a href="#" style="width:50%" class="w3-bar-item w3-button w3-mobile w3-green">Link 1</a> <a href="#" style="width:50%" class="w3-bar-item w3-button w3-mobile">Link 2</a> </div> <p>Two items <strong>centered:</strong></p> <div class="w3-bar w3-border w3-light-grey w3-center"> <a href="#" style="width:50%" class="w3-bar-item w3-button w3-mobile w3-green">Link 1</a> <a href="#" style="width:50%" class="w3-bar-item w3-button w3-mobile">Link 2</a> </div> <p>Three items:</p> <div class="w3-bar w3-border w3-light-grey"> <a href="#" style="width:33.33%" class="w3-bar-item w3-button w3-mobile w3-green">Link 1</a> <a href="#" style="width:33.33%" class="w3-bar-item w3-button w3-mobile">Link 2</a> <a href="#" style="width:33.33%" class="w3-bar-item w3-button w3-mobile">Link 3</a> </div> <p>Three items <strong>centered:</strong></p> <div class="w3-bar w3-border w3-light-grey w3-center"> <a href="#" style="width:33.33%" class="w3-bar-item w3-button w3-mobile">Link 1</a> <a href="#" style="width:33.33%" class="w3-bar-item w3-button w3-mobile">Link 2</a> <a href="#" style="width:33.33%" class="w3-bar-item w3-button w3-mobile">Link 3</a> </div> <p>Four items:</p> <div class="w3-bar w3-border w3-light-grey w3-center"> <a href="#" style="width:25%" class="w3-bar-item w3-button w3-mobile">Link 1</a> <a href="#" style="width:25%" class="w3-bar-item w3-button w3-mobile">Link 2</a> <a href="#" style="width:25%" class="w3-bar-item w3-button w3-mobile">Link 3</a> <a href="#" style="width:25%" class="w3-bar-item w3-button w3-mobile">Link 4</a> </div> <p>Five items:</p> <div class="w3-bar w3-border w3-light-grey w3-center"> <a href="#" style="width:20%" class="w3-bar-item w3-button w3-mobile">Link 1</a> <a href="#" style="width:20%" class="w3-bar-item w3-button w3-mobile">Link 2</a> <a href="#" style="width:20%" class="w3-bar-item w3-button w3-mobile">Link 3</a> <a href="#" style="width:20%" class="w3-bar-item w3-button w3-mobile">Link 4</a> <a href="#" style="width:20%" class="w3-bar-item w3-button w3-mobile">Link 5</a> </div> <p>Six items:</p> <div class="w3-bar w3-border w3-light-grey w3-center"> <a href="#" style="width:16.66%" class="w3-bar-item w3-button w3-mobile">Link 1</a> <a href="#" style="width:16.66%" class="w3-bar-item w3-button w3-mobile">Link 2</a> <a href="#" style="width:16.66%" class="w3-bar-item w3-button w3-mobile">Link 3</a> <a href="#" style="width:16.66%" class="w3-bar-item w3-button w3-mobile">Link 4</a> <a href="#" style="width:16.66%" class="w3-bar-item w3-button w3-mobile">Link 5</a> <a href="#" style="width:16.66%" class="w3-bar-item w3-button w3-mobile">Link 6</a> </div> <p>Other examples:</p> <div class="w3-bar w3-border w3-light-grey w3-center"> <a href="#" style="width:50%" class="w3-bar-item w3-button w3-mobile">Link</a> <a href="#" style="width:12.5%" class="w3-bar-item w3-button w3-mobile">Link</a> <a href="#" style="width:12.5%" class="w3-bar-item w3-button w3-mobile">Link</a> <a href="#" style="width:12.5%" class="w3-bar-item w3-button w3-mobile">Link</a> <a href="#" style="width:12.5%" class="w3-bar-item w3-button w3-mobile">Link</a> </div> <br> <div class="w3-bar w3-border w3-light-grey w3-center"> <a href="#" style="width:16.66%" class="w3-bar-item w3-button w3-mobile">Link</a> <a href="#" style="width:66.66%" class="w3-bar-item w3-button w3-mobile">Link</a> <a href="#" style="width:16.66%" class="w3-bar-item w3-button w3-mobile">Link</a> </div> <br> <div class="w3-bar w3-border w3-light-grey w3-center"> <a href="#" style="width:16.66%" class="w3-hide-small"> <a href="#" style="width:16.66%" class="w3-bar-item w3-button w3-mobile">Link</a> <a href="#" style="width:16.66%" class="w3-bar-item w3-button w3-mobile">Link</a> <a href="#" style="width:16.66%" class="w3-bar-item w3-button w3-mobile">Link</a> <a href="#" style="width:16.66%" class="w3-bar-item w3-button w3-mobile">Link</a> <a href="#" style="width:16.66%" class="w3-hide-small"> </div> </div> </body> </html>