Reputation: 928
I have a css button and I need its width to be 250px, the problem is that when the text in the button is too big the button seems to break in half instead of wrapping.
I have white-space: normal
applied to the button but the break is still happening.
.button {
color: white;
background-color: red;
border: 2px white;
white-space: normal;
padding: 10px 15px;
text-align: center;
}
.container {
max-width: 250px;
}
<div class="container">
<a class="button">my button whose text is longer than 250px</a>
</div>
Upvotes: 1
Views: 164
Reputation: 44
Sometimes on top of using white-space: normal;
ups will also need the element to be display: inline-block;
.button {
color: white;
background-color: red;
border: 2px white;
white-space: normal;
padding: 10px 15px;
text-align: center;
display: inline-block;
}
.container {
max-width: 250px;
}
<div class="container">
<a class="button">my button whose text is longer than 250px</a>
</div>
Upvotes: 1