To ensure your buttons are styled the way you desire, it's important to constrain their width to not exceed 33.33% of the total width on any screen size. To achieve this, you should utilize a parent row
div and enclose each button within a col
div, as illustrated in the code snippet below.
<div class="wrap">
<div class="row">
<div class="col">
<button>Button 1</button>
</div>
<div class="col">
<button>Button 2</button>
</div>
<div class="col">
<button>Button 3</button>
</div>
</div>
Additionally, it's advisable to truncate the text with ellipsis to prevent overflow on smaller screens. Take note of the modifications made to the .button
class in the CSS below.
.wrap {
width: 250px;
height: 50px;
padding: 25px;
text-align: center;
display: inline-block;
width:100%;
}
.col{padding:0 5px;display:inline-block;width:33.33%;}
.row{margin:0 -5px;} /* Customized the .row class of bootstrap */
button{
margin:5px 0; /* to undo your older style */
width:100%;
text-overflow: ellipsis;
white-space:nowrap;
overflow:hidden;
}
button:first-child{
margin:5px 0; /* to undo your older style */
}
For a live demonstration, please refer to the jsfiddle provided