Quantico
Quantico

Reputation: 2446

change bootstrap drop down to drop horizontal right

I have a drop down menu that opens a row of icons underneath it (see picture 1, names and pictures were removed to maintain privacy) enter image description here

I am trying to make this menu to open to the right of choose child, and not underneath it (see picture 2, of what I am trying to get. the Images will open to the right of the drop down and not under it) enter image description here

My current code is:

<div class="span4">      
        <div class="btn-group">
  <a class="btn btn-link dropdown-toggle" data-toggle="dropdown" href="#">
  <h3>Choose Child</h3>
  <img id="mainIcons" src="boyStudent.png" alt="boyStudent">
  <span class="caret"></span></a>
  <ul class="dropdown-menu">
    <li>
        <div class="btn-group">
      <a href="parent_homepage_2.html" style="text-align:center;" class="btn btn-link operationsButtons">
       <h5>A</h5>
       <img id="mainIcons" src="boyStudent.png" alt="boyStudent"></a>
       <a href="parent_homepage_2.html" style="text-align:center;" class="btn btn-link operationsButtons">
       <h5>J</h5>
       <img id="mainIcons" src="girlStudent.png" alt="girlStudent"></a>
     </div>
    </li> 
  </ul>

I tried to use the following example, that helps push the drop down to the left how to make twitter bootstrap submenu to open on the left side? but I could not figure out a way to use this to what I am looking to do

Thanks

Upvotes: 6

Views: 33619

Answers (4)

Andres Felipe
Andres Felipe

Reputation: 4330

I just add this class to the dropdown-menu:

.rightMenu {
    position:absolute;
    float:right;
    top: 0;
    left: 160px;
}

And it aligns perfectly.

Upvotes: 4

btaens
btaens

Reputation: 27

To those who may find this page in the future, the now official way of doing this is with adding the .dropdown-menu-right class to your dropdown list.

Upvotes: 1

Diego Cardenas
Diego Cardenas

Reputation: 393

Just add the class "pull-right" into the <ul class="dropdown-menu"> this way...

<li class="dropdown">
  <a class="dropdown-toggle" href="#">Link</a>
  <ul class="dropdown-menu pull-right">
     <li>...</li>
  </ul>
</li>

Upvotes: 4

PSL
PSL

Reputation: 123739

How does this look:-

Demo

Demo2 Submenu dropping down.

<div class="span4">
    <div class="btn-group"> <a class="btn btn-link dropdown-toggle" data-toggle="dropdown" href="#">
              <h3>Choose Child</h3>
              <img id="mainIcons" src="boyStudent.png" alt="boyStudent">
               <span class="right-caret right"></span>
         </a>

        <ul class="dropdown-menu rightMenu">
            <li>
                <div class="btn-group"> <a href="parent_homepage_2.html" style="text-align:center;" class="btn btn-link operationsButtons">
                   <h5>A</h5>
                   <img id="mainIcons" src="boyStudent.png" alt="boyStudent"></a>
 <a href="parent_homepage_2.html" style="text-align:center;" class="btn btn-link operationsButtons">
                   <h5>J</h5>
                   <img id="mainIcons" src="girlStudent.png" alt="girlStudent"></a>

                </div>
            </li>
        </ul>
    </div>

css

   .rightMenu {
    position:relative;
    float:right;
}
.right-caret {
    
    border-bottom: 4px solid transparent;
    border-top: 4px solid transparent;
    border-left: 4px solid #000000;
    display: inline-block;
    height: 0;
    opacity: 1;
    vertical-align: top;
    width: 0;
    
}
.right
{
    float:right;
}

Upvotes: 10

Related Questions