Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overflowing button text is being clipped in safari

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

like image 255
blackmamba Avatar asked Dec 12 '16 11:12

blackmamba


People also ask

How do I stop Div text-overflow?

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.

How do I fix text-overflow in CSS?

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.

What is text-overflow?

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.

How do you change text-overflow on ellipsis?

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.


1 Answers

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.

like image 80
blackmamba Avatar answered Oct 16 '22 11:10

blackmamba