I have a simple button tag and I specifically want the text to overflow the button. This works fine in current browsers with the exception of Safari (ios and osx) which clips the text at the button boundary.
button,
.button {
width: 100px;
overflow: visible;
white-space: nowrap;
text-overflow: 'clip';
text-align: left;
-webkit-appearance: none;
background: none;
border: none
}
<button>Very long text Very long text Very long text This Clips In Safari</button>
<div class='button'>Very long text Very long text Very long text This Overflows</div>
I can't figure out how to get the text to overflow. Does anyone know how to make this work. TIA
To fix this problem, avoid using vw for your max-width and use a max-width of 100% instead. This will transfer the width of the parent container to the width of the child container.
A text-overflow property in CSS is used to specify that some text has overflown and hidden from view. The white-space property must be set to nowrap and the overflow property must be set to hidden. The overflowing content can be clipped, display an ellipsis ('…'), or display a custom string.
Definition and Usage. The text-overflow property specifies how overflowed content that is not displayed should be signaled to the user. It can be clipped, display an ellipsis (...), or display a custom string.
To clip at the transition between characters you can specify text-overflow as an empty string, if that is supported in your target browsers: text-overflow: ''; . This keyword value will display an ellipsis ( '…' , U+2026 HORIZONTAL ELLIPSIS ) to represent clipped text.
So eventually I found a work around.
If I wrap the text in a span and then set the span to position:relative the overflowing text will display correctly without being clipped.
Also note the recommendation above to use text-overflow:clip is wrong, has no impact on this and text-overflow:'' is valid.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With