How to get a Bootstrap dropdown submenu to 'dropup' - html

I have a Bootstrap dropdown menu. The last li item is a submenu. How do I get the submenu to dropup while the full menu drops down? Here's the code:
<div class="dropdown">
<a class="inputBarA dropdown-toggle" data-toggle="dropdown" href="#">FILTER</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<li role="presentation">
<a role="menuitem" href="#">Text</a>
</li>
<li role="presentation">
<label>Label name</label>
<label>Label name</label>
<label class="checkbox">
<input type="checkbox">
Text </label>
<label class="checkbox">
<input type="checkbox">
Text </label>
<label class="checkbox">
<input type="checkbox">
Text </label>
<label class="checkbox">
<input type="checkbox">
Text </label>
</li>
<li class="dropdown-submenu">
<a tabindex="-1" href="#">Centralities</a>
<ul class="dropdown-menu">
<label class="radio">
<input type="radio" name="options" id="optionsRadios1" value="A" checked>
AA </label>
<label class="radio">
<input type="radio" name="options" id="optionsRadios2" value="B">
BB </label><label class="radio">
<input type="radio" name="options" id="optionsRadios2" value="C">
CC </label><label class="radio">
<input type="radio" name="options" id="optionsRadios2" value="D">
DD </label><label class="radio">
<input type="radio" name="options" id="optionsRadios2" value="E">
EE </label>
</ul>
</li>
</ul>
</div>

The best solution:
<div class="dropup">
<ul class="dropdown-menu"></ul>
</div>
It's a native class in bootstrap. The bootstrap (using 3.1.1) css file has a .dropup .dropdown-menu selector so that's how I found out.

It sounds like the answer below would be how to do it from scratch, I was unaware there was a dropup class in Bootstrap...
So the short Bootstrap answer is to apply the class "dropup" to the <ul> in earlier versions of bootstrap:
<ul class="dropdown-menu dropup" role="menu" aria-labelledby="dLabel">
However in newer versions of bootstrap (v3) the "dropup" class needs to be applied to the <ul>'s container instead of the the <ul> itself:
<div class="dropup">
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
</div>
See http://jsfiddle.net/ZgyZP/5/
Original working answer that doesn't use bootstrap:
You could use javascript to calculate the height of the submenu and then negatively offset the submenu's position.
something like (with jQuery):
$('.dropdown-submenu').hover(
function(){
//hover in
$('.dropdown-submenu > ul').css('top', '-' + $('.dropdown-submenu > ul').css('height'));
},
//hover out
function(){
}
);
Fiddle: http://jsfiddle.net/ZgyZP/4/

Use a class, like up
<ul class="dropdown up">
Write style of up
.up { bottom:100% !important; top:auto !important; }
Note: Increase bottom as per your button size.

<div class="dropup">
<ul class="dropdown-menu"></ul>
</div>
The above code is correct, but doesn't work unless a parent element has the position property set.
Examples that works are class="col-lg-12" or just
<div style="position: relative;">
I use Bootstrap v3.0.0.

I used the dropup Class, and it worked perfectly as i expected it.
<div class="col-md-6 dropup">
<span uib-dropdown auto-close="outsideClick">
<p class="input-group">
<input type="text" class="form-control" ng-model="int.schTimeFormatted" ng-disabled="true" name="schTime" />
<span class="input-group-btn">
<button type="button" class="btn btn-default cal" uib-dropdown-toggle>
<i class="glyphicon glyphicon-time"></i>
</button>
</span>
</p>
<ul class="dropdown-menu" uib-dropdown-menu aria-labelledby="simple-dropdown">
<li class="timerDropdown">
<div class="row">
<div class="col-md-6">
<div uib-timepicker ng-model="int.schTime" ng-change="changed()" hour-step="hstep" minute-step="mstep" readonly-input="true" min="min"
max="max" show-meridian="ismeridian"></div>
</div>
<div>
Booked Timeslots
<ul id="timeListB">
<li ng-repeat="time in bookedTimeslots">{{time | date:"h:mma"}}</li>
</ul>
</div>
</div>
<hr>
<button class="pull-right">close</button>
</li>
</ul>
</span>
</div>

Related

Narrator announces incorrect information as "non-selected" when focus moves to the radio button

Narrator announces incorrect information as "non-selected" when focus moves to the radio button.
it should be speaking about radio button selected 1 of 2
<div>
<div tabindex="0" role="radio">
<ul>
<li class="react-custom-radio-link">
<input type="radio" name="IsPrivateProfile" id="Public" aria-checked="true">
<label for="Public">Public</label></li>
</ul>
</div>
<div tabindex="0" role="radio">
<ul class="react-custom-radio-button">
<li class="react-custom-radio-link">
<input type="radio" name="IsPrivateProfile" id="Private" aria-checked="false" checked=""><label for="Private">Private</label></li>
</ul>
</div>
</div>
It happens because it focuses first on the div which has a tabindex attribute. If you continue to the radio it will announce the correct status. My fix was to remove the focus-ability from the div
<div>
<div role="radio">
<ul>
<li class="react-custom-radio-link">
<input type="radio" name="IsPrivateProfile" id="Public" aria-checked="true">
<label for="Public">Public</label></li>
</ul>
</div>
<div role="radio">
<ul class="react-custom-radio-button">
<li class="react-custom-radio-link">
<input type="radio" name="IsPrivateProfile" id="Private" aria-checked="false" checked=""><label for="Private">Private</label></li>
</ul>
</div>
</div>

Truncate on x-overflow inside list item

Is there a way to make the nice text-overflow: ellipsis; work on long names (class name) in my list, adding to this CSS & HTML? Note how the 55026 ID is wrapped below in an ugly fashion on the last time.
.my-list {
width: 275px;
}
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" />
<ul class="list-group my-list">
<li class="preferred-payer list-group-item">
<label class="checkbox-inline">
<input id="option-one" type="checkbox" name="select" value="60054">
<span class="name">Item Name One</span>
</label>
<span class="id pull-right">60054</span>
</li>
<li class="preferred-payer list-group-item">
<label class="checkbox-inline">
<input id="option-one" type="checkbox" name="select" value="00562">
<span class="name">Item Name Two</span>
</label>
<span class="id pull-right">00562</span>
</li>
<li class="preferred-payer list-group-item">
<label class="checkbox-inline">
<input id="option-one" type="checkbox" name="select" value="55026">
<span class="name">A Really Long Item To Truncate </span>
</label>
<span class="id pull-right">55026</span>
</li>
</ul>
You can consider a row/col configuration then add overflow:hidden to truncate the text:
.my-list {
width: 275px;
padding: 0 15px;
}
.my-list>.row {
margin: 0;
}
label {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" />
<ul class="list-group my-list">
<li class="preferred-payer list-group-item row ">
<label class="checkbox-inline col-xs-9">
<input id="option-one" type="checkbox" name="select" value="60054">
<span class="name">Item Name One</span>
</label>
<span class="id pull-right col-xs-3">60054</span>
</li>
<li class="preferred-payer list-group-item row">
<label class="checkbox-inline col-xs-9">
<input id="option-one" type="checkbox" name="select" value="00562">
<span class="name">Item Name Two</span>
</label>
<span class="id pull-right col-xs-3">00562</span>
</li>
<li class="preferred-payer list-group-item row">
<label class="checkbox-inline col-xs-9">
<input id="option-one" type="checkbox" name="select" value="55026">
<span class="name ">A Really Long Item To Truncate </span>
</label>
<span class="id pull-right col-xs-3">55026</span>
</li>
</ul>

My navbar dropdown is not overlaying my header even with position relative and z-index

I'm trying to make a login dropdown from my navbar overlay the header of the page. The navbar and dowdown use ui bootstrap.
I tried the following:
1. #login-dp{
min-width: 200px;
padding: 14px 14px 0;
position: relative;
z-index: 1000;
}`
I tried wraping the ul with that class and setting the wraper position to absolute (that fixed 2 other elements from going bunkers when I click the dropdown)
I tried setting the #login-dp to absolute and the wraper to relative
Most of the solutions I found only mention about the position and z-index.
Here is some code:
<ul class="nav navbar-nav navbar-right">
<li><p class="navbar-text">Already have an account?</p></li>
<li class="dropdown">
<b>Login</b> <span class="caret"></span>
<div class="wraper1">
<ul id="login-dp" class="dropdown-menu dropdown-menu-right" uib-collapse="isDropCollapsed">
<li>
<div class="row">
<div class="col-md-12">
<!--<p>Login via</p>
<div class="social-buttons">
<i class="fa fa-facebook"></i> Facebook
<i class="fa fa-twitter"></i> Twitter
</div>
<p>or</p>-->
<form class="form" role="form" method="post" action="login" accept-charset="UTF-8" id="login-nav">
<div class="form-group">
<label class="sr-only" for="exampleInputEmail2">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail2" placeholder="Email address" required>
</div>
<div class="form-group">
<label class="sr-only" for="exampleInputPassword2">Password</label>
<input type="password" class="form-control" id="exampleInputPassword2" placeholder="Password" required>
<div class="help-block text-right">Forget the password ?</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary btn-block">Sign in</button>
</div>
<div class="checkbox">
<label>
<input type="checkbox"><p>keep me logged-in</p>
</label>
</div>
</form>
</div>
<div class="bottom text-center">
<p>New here?</p> <b>Join Us</b>
</div>
</div>
</li>
</ul>
</div>
</li>
</ul>
Hope you can help

Align 3 elements inside a list-group-item in bootstrap

I'm trying to align a radio button, an input and some text inside one of my list-group-items, it looks good #desktop but #mobile it goes one on top of the other.
This is my code so far
<div class="panel panel-default">
<div class="panel-body">
<span style="color: #990000; font-size:17px;"><strong>8,55 €</strong></span> text
<ul class="list-group">
<li class="list-group-item"><input name="1" type="radio"> 1 text <strong>8,55 €</strong></li>
<li class="list-group-item"><input name="2" type="radio"> 3 text <strong>8,55 €</strong></li>
<li class="list-group-item"><input name="3" type="radio"> 6 text <strong>8,55 €</strong></li>
<li class="list-group-item">
<div class="container-fluid">
<div class="row">
<div class="col-md-1"><input name="n" type="radio" ></div><div class="col-md-3"><input type="text" name ="text" id="amount" class="form-control" placeholder="12"></div><div class="col-md-8" >text<strong>8,55 €</strong></div>
</div>
</div>
</li>
</ul>
</div>
</div>
Is there anything I can do to have it responsive and aligned in mobile as well as dekstop?
You can use col-xs-* in place of col-md-*: fiddle example
<div class="col-xs-1">
<input name="n" type="radio" >
</div>
<div class="col-xs-3">
<input type="text" name ="text" id="amount" class="form-control" placeholder="12">
</div>
<div class="col-xs-8" >
text<strong>8,55 €</strong>
</div>

Radio buttons don't align properly in a menu

I have a nav-bar with a menu with radio buttons as menu elements, but they don't aligh well:
<!DOCTYPE HTML>
<div class="navbar">
<div class="navbar-inner">
<ul class="nav pull-right">
<li>
<form method="get" action="search" class="navbar-form pull-right">
<input type="text" name="q" class="input-medium search-query" placeholder="Search">
</li>
<li id="nav_search_filter" class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#"><b class="caret"></b></a>
<ul class="dropdown-menu">
<li>Search:</li>
<li>
<input type="radio" id="search_filter_all" name ="search_filter" value="all" checked="checked"/>
<label for="search_filter_all">All</label>
</li>
<li><input type="radio" id="search_filter_inactive" name ="search_filter" value="inactive" /> <label for="search_filter_inactive">Inactive</label></li>
<li><input type="radio" id="search_filter_active" name ="search_filter" value="active" /> <label for="search_filter_active">Active</label></li>
</ul>
</li>
</form>
</ul>
</div>
</div>
http://jsfiddle.net/2SmWq/
You could try something like this:
label {margin:10px;}
input[type="radio"] {display:inline-block; vertical-align:top;}
and wrapping the labels around the input tags in the html.
here is a jsfiddle to see what I mean.
Hope this helps.
If what you want it do have the radio button and the label in the same line. Try this:
<style>
label {
display:inline-block;
}
</style>