Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap dropdown: how to make text wrap nicely

I am learning Bootstrap. I would like to have a button with dropdown such as the following:

<div class="btn-group">
  <a class="btn dropdown-toggle btn-mini" data-toggle="dropdown" href="#">
    Action
    <span class="caret"></span>
  </a>
  <div class="dropdown-menu" style="width: 300px;">
    <div >

  Long text goes here.

    </div>
  </div>
</div>

Instead of dropdown menu, I have <div> with long text and other html tags. The problem is that I tried different CSS rules and the long text either extends beyond the <div> or causes scroll bars to show up. I just want the long text wrap nicely within the <div> and goes down depending on the amount of text.

How can I do this?

Am I using "dropdown-menu" component the wrong way?

like image 327
curious1 Avatar asked Jul 26 '13 13:07

curious1


People also ask

How do I style a dropdown in Bootstrap?

Basic Dropdown To open the dropdown menu, use a button or a link with a class of . dropdown-toggle and the data-toggle="dropdown" attribute. The . caret class creates a caret arrow icon (), which indicates that the button is a dropdown.

How do I handle a long text in DropDownList?

//On focus out set the original width of DropDownList. Apply the Css Class adjust-width to all ASP.Net DropDownLists for which you want handle long text as shown below. Apply the Css Class adjust-width to all HTML SELECT DropDownLists for which you want handle long text as shown below.

How do I style a drop down list?

HTML) Use any element to open the dropdown content, e.g. a <span>, or a <button> element. Use a container element (like <div>) to create the dropdown content and add whatever you want inside of it. Wrap a <div> element around the elements to position the dropdown content correctly with CSS.


1 Answers

Just add white-space: normal; to your .dropdown-menu

Example fiddle

like image 86
omma2289 Avatar answered Oct 24 '22 02:10

omma2289