Bujji
Bujji

Reputation: 1727

Boostrap dropdown-menu header width and caret

For dropdown menu , if I fix the size of menu heading and use text-overflow: ellipsis; this also takes off caret symbol . You can see it here and below is the code

http://jsfiddle.net/bZw8X/1/

<div class="navbar navbar-inner">
                    <ul class="nav">  
<li class="dropdown">
     <a  href="#" class="dropdown-toggle" data-toggle="dropdown">This is my test heading <b class="caret"></b></a>
                            <ul class="dropdown-menu">
                                 <li><a href="editProfile"> Edit Profile </a></li>
                                <li><a href="logout/"><i class="icon-block"></i> Logout</a></li>
                            </ul>
 </li> 


<li class="dropdown">
     <a  href="#" class="dropdown-toggle" data-toggle="dropdown">Second <b class="caret"></b></a>
                            <ul class="dropdown-menu">
                                 <li><a href="editProfile"> Edit Profile </a></li>
                                <li><a href="logout/"><i class="icon-block"></i> Logout</a></li>
                            </ul>
 </li>                         

       </ul> 
                </div>

Is there any way ( hack) I can get caret here ?

Thank You

Upvotes: 2

Views: 2005

Answers (2)

Mark
Mark

Reputation: 595

Here is a solution that wraps the text in its own div.

http://jsfiddle.net/alforno/XSpZv/1/

.ael {
  width:100px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden !important;
  float:left;
}

And the html changed to this:

<li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">
    <div class="ael">This is my test heading</div> <b class="caret"></b>
    </a>

    <ul class="dropdown-menu">
        <li><a href="editProfile"> Edit Profile </a></li>
        <li><a href="logout/"><i class="icon-block"></i> Logout</a></li>
    </ul>
</li>

Upvotes: 3

Derek
Derek

Reputation: 3435

Add the caret before the text, and float it right.

<b class="caret pull-right">This is my test heading

Updated Fiddle

Upvotes: 3

Related Questions