Bootstrap Series--27. Drop-down menu alignment

Source: Internet
Author: User

The bootstrap Frame drop-down menu is left-aligned by default, and you can add a "pull-right" or "Dropdown-menu-right" on "Dropdown-menu" If you want the drop-down menu to be right-aligned relative to the parent container The class name.

<h4>Use the Pull-right class to align the drop-down menu to the right of the parent container</h4> <Divclass= "Dropdown">  <Buttonclass= "btn btn-default dropdown-toggle"type= "button"ID= "DropdownMenu1"Data-toggle= "Dropdown">Drop- down menu<spanclass= "Caret"></span>  </Button>  <ulclass= "Dropdown-menu pull-right"role= "Menu"Aria-labelledby= "DropdownMenu1">    <Lirole= "Presentation"><arole= "MenuItem"TabIndex= "-1"href="#">Drop-down menu item</a></Li>    <Lirole= "Presentation"><arole= "MenuItem"TabIndex= "-1"href="#">Drop-down menu item</a></Li>    <Lirole= "Presentation"><arole= "MenuItem"TabIndex= "-1"href="#">Drop-down menu item</a></Li>    <Lirole= "Presentation"class= "Divider"></Li>    <Lirole= "Presentation"><arole= "MenuItem"TabIndex= "-1"href="#">Drop-down menu item</a></Li>  </ul></Div><BR/><BR/><h4>Use the Dropdown-menu-right class to align the drop-down menu to the right of the parent container</h4><Divclass= "Dropdown">  <Buttonclass= "btn btn-default dropdown-toggle"type= "button"ID= "DropdownMenu1"Data-toggle= "Dropdown">Drop- down menu<spanclass= "Caret"></span>  </Button>  <ulclass= "Dropdown-menu dropdown-menu-right"role= "Menu"Aria-labelledby= "DropdownMenu1">    <Lirole= "Presentation"><arole= "MenuItem"TabIndex= "-1"href="#">Drop-down menu item</a></Li>    <Lirole= "Presentation"><arole= "MenuItem"TabIndex= "-1"href="#">Drop-down menu item</a></Li>    <Lirole= "Presentation"><arole= "MenuItem"TabIndex= "-1"href="#">Drop-down menu item</a></Li>    <Lirole= "Presentation"class= "Divider"></Li>    <Lirole= "Presentation"><arole= "MenuItem"TabIndex= "-1"href="#">Drop-down menu item</a></Li>  </ul></Div> <BR/><BR/><h4>The drop-down menu aligns to the left of the parent container</h4><Divclass= "Dropdown">  <Buttonclass= "btn btn-default dropdown-toggle"type= "button"ID= "DropdownMenu1"Data-toggle= "Dropdown">Drop- down menu<spanclass= "Caret"></span>  </Button>  <ulclass= "Dropdown-menu dropdown-menu-left"role= "Menu"Aria-labelledby= "DropdownMenu1">    <Lirole= "Presentation"><arole= "MenuItem"TabIndex= "-1"href="#">Drop-down menu item</a></Li>    <Lirole= "Presentation"><arole= "MenuItem"TabIndex= "-1"href="#">Drop-down menu item</a></Li>    <Lirole= "Presentation"><arole= "MenuItem"TabIndex= "-1"href="#">Drop-down menu item</a></Li>    <Lirole= "Presentation"class= "Divider"></Li>    <Lirole= "Presentation"><arole= "MenuItem"TabIndex= "-1"href="#">Drop-down menu item</a></Li>  </ul></Div> 

At the same time, there is a class name "Dropdown-menu-left" with the same class name as the "Dropdown-menu-right", and the effect is to have the drop-down menu aligned to the left of the parent container, which is actually the default effect

There is a problem here, if the right alignment, although the style is set, but it is easy to show the style confusion, the drop-down menu position is <div class= "dropdown" > Width to determine, so at different resolutions will vary.

The solution here is to fix the width of the Div, and one is to put the button on the right.

Bootstrap Series--27. Drop-down menu alignment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.