W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <head> <style> .btn-group .button { background-color: #4CAF50; /* 绿色 */ border: 1px solid green; color: white; padding: 15px 32px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; cursor: pointer; float: left; } .btn-group .button:not(:last-child) { border-right: none; /* 阻止双边框 */ } .btn-group .button:hover { background-color: #3e8e41; } </style> </head> <body> <h1>带边框的按钮组</h1> <p>添加边框,来创建带按钮的按钮组:</p> <div class="btn-group"> <button class="button">Button</button> <button class="button">Button</button> <button class="button">Button</button> <button class="button">Button</button> </div> <p style="clear:both"><br>请记得之后清除浮动,否则这个 p 元素会向按钮浮动。</p> </body> </html>