Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

twitter bootstrap issue : Right align the caret in the dropdown header

Tags:

I have an issue with the right alignment of the caret. Using .pull-right in the span makes it go to the top right corner.

How can I make it vertically centered again ? I also would like to align the text to the left

http://www.bootply.com/r8x7g5Bw5R

                    <div class="btn-group cust-dropdown">                     <button type="button" class="btn btn-default dropdown-toggle cust-dropdown" data-toggle="dropdown"><span class="caret pull-right"></span><span>test</span>                     </button>                     <ul class="dropdown-menu" role="menu">                         <li><a href="#">test</a></li>                         <li><a href="#">tes2</a></li>                         <li><a href="#">test3</a></li>                     </ul>                 </div> 

and the CSS

.cust-dropdown { width: 200px;} 
like image 303
Franckl Avatar asked Jun 02 '14 20:06

Franckl


People also ask

How do I align a drop down to the right?

Use the w3-right class to float the dropdown to the right, and use CSS to position the dropdown content (right:0 will make the dropdown menu go from right to left).

How do I move a drop down to the right in Bootstrap?

To right-align a menu, use . dropdown-menu-right. Right-aligned nav components in the navbar use a mixin version of this class to automatically align the menu. To override it, use .

How Align drop down menu in Bootstrap Center?

Dropdown button can be positioned in the center of the page by setting the “text-align” property of dropdown div to center. The following example contains a simple Bootstrap dropdown menu with an added class “my-menu”. The property “text-align: center” is added to the class.

How do you open Bootstrap dropdown menu on hover rather than click?

Answer: Use the jQuery hover() method By default, to open or display the dropdown menu in Bootstrap you have to click on the trigger element. However, if you want to show the dropdown on mouseover instead of click you can do it with little customization using the CSS and jQuery.


1 Answers

.caret {     border-left: 6px solid transparent;     border-right: 6px solid transparent;     border-top: 8px solid #fff;     left: 90%;     top: 45%;     position: absolute; } 

Using position absolute and a percentage top and left I was able to right align my caret within the dropdown. Works in Chrome, IE, and FF.

EDIT

Previous code will work but changes the style of the caret. If you just want to reposition it maintaining its style, just extend Bootstrap's .caret class:

.caret {     position: absolute;     left: 90%;     top: 45%; } 
like image 71
FiveTools Avatar answered Oct 21 '22 05:10

FiveTools