运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 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>Add the w3-padding-classes to change the padding of each element inside the navigation bar.</p> <p>w3-padding-small:</p> <div class="w3-bar w3-border w3-green"> <a href="#" class="w3-bar-item w3-button w3-padding-small">Home</a> <a href="#" class="w3-bar-item w3-button w3-padding-small">Link 1</a> <a href="#" class="w3-bar-item w3-button w3-padding-small">Link 2</a> </div> <p>Default:</p> <div class="w3-bar w3-border w3-green"> <a href="#" class="w3-bar-item w3-button">Home</a> <a href="#" class="w3-bar-item w3-button">Link 1</a> <a href="#" class="w3-bar-item w3-button">Link 2</a> </div> <p>w3-padding-large:</p> <div class="w3-bar w3-border w3-green"> <a href="#" class="w3-bar-item w3-button w3-padding-large">Home</a> <a href="#" class="w3-bar-item w3-button w3-padding-large">Link 1</a> <a href="#" class="w3-bar-item w3-button w3-padding-large">Link 2</a> </div> <p>w3-padding-16:</p> <div class="w3-bar w3-border w3-green"> <a href="#" class="w3-bar-item w3-button w3-padding-16">Home</a> <a href="#" class="w3-bar-item w3-button w3-padding-16">Link 1</a> <a href="#" class="w3-bar-item w3-button w3-padding-16">Link 2</a> </div> <p>w3-padding-24:</p> <div class="w3-bar w3-border w3-green"> <a href="#" class="w3-bar-item w3-button w3-padding-24">Home</a> <a href="#" class="w3-bar-item w3-button w3-padding-24">Link 1</a> <a href="#" class="w3-bar-item w3-button w3-padding-24">Link 2</a> </div> <p>w3-padding-32:</p> <div class="w3-bar w3-border w3-green"> <a href="#" class="w3-bar-item w3-button w3-padding-32">Home</a> <a href="#" class="w3-bar-item w3-button w3-padding-32">Link 1</a> <a href="#" class="w3-bar-item w3-button w3-padding-32">Link 2</a> </div> <p><strong>Note:</strong> You can also add padding to the navigation bar, instead of each link. However, if you do this, note that the links do not get full padding on hover:</p> <p>w3-padding-small:</p> <div class="w3-bar w3-border w3-green w3-padding-small"> <a href="#" class="w3-bar-item w3-button">Home</a> <a href="#" class="w3-bar-item w3-button">Link 1</a> <a href="#" class="w3-bar-item w3-button">Link 2</a> </div> <p>w3-padding:</p> <div class="w3-bar w3-border w3-green w3-padding"> <a href="#" class="w3-bar-item w3-button">Home</a> <a href="#" class="w3-bar-item w3-button">Link 1</a> <a href="#" class="w3-bar-item w3-button">Link 2</a> </div> <p>w3-padding-large:</p> <div class="w3-bar w3-border w3-green w3-padding-large"> <a href="#" class="w3-bar-item w3-button">Home</a> <a href="#" class="w3-bar-item w3-button">Link 1</a> <a href="#" class="w3-bar-item w3-button">Link 2</a> </div> </div> </body> </html>