Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrapping a word using CSS after n number characters or pixels

I am using this link. http://lodev09.github.io/bootstrap-suggest/

On this page, when you start typing with @ characters in the first textbox, system shows a dropdown with certain values. I want to ensure, after every 20 characters system should wrap the text in the next line.

I tried adding following style to <li> tag but it did not helped.

word-wrap:break-word;
max-width:30px;
like image 687
OpenStack Avatar asked Oct 26 '25 16:10

OpenStack


2 Answers

I would use something like:

li { 
     word-wrap: break-word; 
     max-width: 20ch;
}

It doesn't break the word at 20 characters but rather wraps the text when it hits the 20 character limit.

like image 118
Neil Clayton Avatar answered Oct 28 '25 07:10

Neil Clayton


adding this class helped:

.dropdown.suggest>.dropdown-menu>li>a {
    white-space: normal;
}
like image 41
OpenStack Avatar answered Oct 28 '25 07:10

OpenStack