HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
Learn how to create a "button group" with CSS
Group a series of buttons together on a single line in a button group:
Step 1) Add HTML:
<div class="btn-group">
<button>Apple</button>
<button>Samsung</button>
<button>Sony</button>
</div>
Step 2) Add CSS:
.btn-group button {
background-color: #04AA6D; /* Green
background */
border: 1px solid green; /* Green border
*/
color: white; /* White text */
padding: 10px
24px; /* Some padding */
cursor: pointer; /*
Pointer/hand icon */
float: left; /* Float the
buttons side by side */
}
.btn-group button:not(:last-child) {
border-right: none; /* Prevent double borders */
}
/* Clear floats (clearfix hack) */
.btn-group:after {
content: "";
clear: both;
display:
table;
}
/* Add a background color on hover */
.btn-group button:hover {
background-color: #3e8e41;
}
Try it Yourself »
<!-- Three buttons in a group -->
<div class="btn-group" style="width:100%">
<button
style="width:33.3%">Apple</button>
<button style="width:33.3%">Samsung</button>
<button
style="width:33.3%">Sony</button>
</div>
<!--
Four buttons in a group -->
<div class="btn-group" style="width:100%">
<button
style="width:25%">Apple</button>
<button style="width:25%">Samsung</button>
<button
style="width:25%">Sony</button>
<button
style="width:25%">HTC</button>
</div>
Try it Yourself »