Wrap text on 2 lines for smallest width

I have a button with a flexible width. I would like to let the text wrap to 2 lines to keep the button’s width as small as possible. Below are some examples.

Short words should still be wrapped to 2 lines to keep the button width small:


A long description should wrap to the smallest resulting width:

My button with 
very long text 

A long word should just stay on one line, and the button will be larger:


I’ve only managed to make the button wrap if I give it a width, but I want the width to be flexible. Is that possible?

My last resort would be to parse the text with js and add a <br> element, but if a more elegant CSS solution exists I would prefer that.

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Article

NovaCHARGE deploys 627 charging ports for Florida’s Park & Plug program - Charged EVs

Next Article

MotoGP Le Mans: ’Stay calm, understand and win’ - Bastianini

Related Posts