I'm trying to use a dropdown zone to host a custom component. however, the dropdown is not from a standard dropdown but from an input group button.
I need this because I want a jstree down there as my selection need is too complex to fit in a simple select.
Here is what I would it to be like :
I would like for the dropdown zone to be the full width of the input. I've tried setting it at 100% but it seam to do nothing. A fixed with work but would break the responsivness of the site.
Here is my HTML :
<div class="col-md-3">
<fieldset>
<legend>Options</legend>
<div class="form-group">
<div class="input-group">
<input type="text" class="form-control">
<div class="input-group-btn">
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown" type="button"><span class="caret"></span></button>
<ul class="dropdown-menu dropdown-menu-right" role="menu" style="width: 300px;">
<li>
aaaa<br />
aaaa<br />
aaaa<br />
aaaa<br />
</li>
</ul>
</div>
</div>
</div>
</fieldset>
</div>
Full jsfiddle : https://jsfiddle.net/rry7hr5b/1/
Try this.
With Jquery.
$(document).ready(function(e) {
function customwidth()
{
var formwidth = $('.form-group').width();
$('.dropdown-menu').width(formwidth);
}
customwidth();
$(window).resize(function(e) {
customwidth();
});
});
I found a workaround using the .input-group-addon instead of the .input-group-btn. It's neat, because you need no plugins or jQuery whatsoever. Mind however that the whole dropdown menu requires a minimum width.
<div class="input-group">
<input type="text" class="form-control">
<div class="input-group-addon" style="padding:0; border:none; background:none">
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown" type="button" style="border-bottom-left-radius:0; border-top-left-radius:0">
<span class="caret"></span>
</button>
</div>
<ul class="dropdown-menu" role="menu" style="width:100%;">
<li>aa</li>
<li>aa</li>
<li>aa</li>
</ul>
</div>
Check out this fiddle: https://jsfiddle.net/rry7hr5b/5/
Don't use this kind of ul li for select item to customize Select in bootstrap there is plug-in available please try this
http://silviomoreto.github.io/bootstrap-select/
and here some more link..
http://gregfranko.com/jquery.selectBoxIt.js/
Related
I'm creating a query form using bootstrap's 12 column grid system (version 3). The layout consists of dropdown menu where a user can select an item.
The Problem:
When a user selects a value from the dropdown menu, the element overflows into the next column. Is there a recommended solution for correcting this?
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-md-1">
</div>
<div class="col-md-4">
<input type="text" />
</div>
<div class="col-md-3">
<div class="btn-group" uib-dropdown>
<button id="btn-append-to-body" type="button" class="btn btn-secondary" uib-dropdown-toggle="">
{{importTGModal.paramCondition1_selected}}
<span class="caret">
</span>
</button>
<ul class="dropdown-menu" ng-click="importTGModal.setParamCondition1($event)" uib-dropdown-menu="" role="menu" aria-labelledby="btn-append-to-body">
<li role="menuitem" ng-repeat="condition in importTGModal.paramConditions1">
<a data-value={{condition}}>{{condition}}
</a>
</li>
</ul>
</div>
</div>
<div class="col-md-4">
<input type="text" />
</div>
</div>
That's because the dropdown is larger than the container column.
Try one of the following:
1- (Recommended) Put the dropdown and the input text in same column
2- Make the column of the dropdown bigger. Like col-md-6
3- (Not Recommended) Bootstrap class .btn adds white-space: nowrap;. Set it to white-spsace: normal for this button, so if the button has long text (bigger than the column) the text will break to next line. Like so:
<button id="btn-append-to-body" type="button" class="btn btn-secondary" uib-dropdown-toggle="" style="white-space: normal;">
I have a problem when I use inline-form the input text does not take all the space.
I am aware of that information, but I am a bootstrap beginner.
Requires custom widths Inputs, selects, and textareas are 100% wide by
default in Bootstrap. To use the inline form, you'll have to set a
width on the form controls used within. The default width of 100% as
all form elements gets when they got the class form-control didn't
apply if you use the form-inline class on your form.
Cordially
<div class="panel panel-primary">
<div class="panel-heading"><h4>Search Options</h4></div>
<div class="panel-body">
<form class="form-inline">
<div class="form-group">
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle"
data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false">
Account ID <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>Account ID</li>
<li>Company Name</li>
<li>Account Type</li>
<li role="separator" class="divider"></li>
<li>Marketplaces</li>
</ul>
</div>
</div>
<div class="form-group">
<input class="form-control" type="text"
value="" id="filter_id" placeholder="Put your filter here">
<button type="button" class="btn btn-default"> Filtrer </button>
</div>
</form>
</div>
</div>
According to Docs
May require custom widths
Inputs and selects have width: 100%; applied by default in Bootstrap.
Within inline forms, we reset that to width: auto; so multiple
controls can reside on the same line. Depending on your layout,
additional custom widths may be required.
EDIT
as per your comment:
the input text take the rest of space. I want inline all the elements
in a single row and if a space is left the input text should take it
use flexbox
/* !important ONLY USED FOR SNIPPET */
.form-inline {
display: flex
}
.flex {
flex: 1;
display: flex !important
}
.flex input {
flex: 1 !important
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="panel panel-primary">
<div class="panel-heading">
<h4>Search Options</h4>
</div>
<div class="panel-body">
<form class="form-inline">
<div class="form-group">
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Account ID <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>Account ID</li>
<li>Company Name</li>
<li>Account Type</li>
<li role="separator" class="divider"></li>
<li>Marketplaces</li>
</ul>
</div>
</div>
<div class="form-group flex">
<input class="form-control" type="text" value="" id="filter_id" placeholder="Put your filter here">
<button type="button" class="btn btn-default"> Filtrer </button>
</div>
</form>
</div>
</div>
Add a container as a 'context' in your markup and then use it to override your css in this specific context :
<div class="special-form">
<!-- form -->
</div>
CSS
.special-form .panel .form-control {
width: 100%;
}
On this page: (link removed)
I'm starting to build a tumblr theme, and I have decided to build it using bootstrap. If you click the little I info button in the left corner, a div comes down with a user picture and description. The user picture and description appear as I want them to, but they are off center. I'd like them to be centered. I've tried < center >, using a fluid width container, etc with no avail. I also checked and bootstrap.css and the bootstrap.min.js are properly linked to the page.
Any help with this would be GREAT!
My code:
<div class="container-fluid" id="foo" style="z-index:5; display:none; height:auto;">
<center>
<div class="container-fluid" style="height:auto;">
<div class="row">
<div class="col-md-2" style=" margin-top:1%;"><img class="avatar-style-circle" src="{PortraitURL-128}" /><br/><h3>{AuthorName}</h3></div>
<div class="col-xs-12 col-md-8" style="background-color:blue; margin-top:3%;"><p style="text-align:justify;">{Description}<br/></p></div></div></div>
<div class="container-fluid" style="height:auto; margin-bottom:2%;">
<center>
<div class="container-fluid">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search for...">
<span class="input-group-btn">
<button class="btn btn-default" type="button">Go!</button>
</span>
</div><!-- /input-group -->
<br/>
<div class="btn-group" role="group" aria-label="..."> Ask
Archive
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
Dropdown
<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" style="z-index:5; margin-left:13%;">
<li>Dropdown link</li>
<li>Dropdown link</li>
</ul>
</div><!-- /.col-lg-6 --></center>
</div>
</div>
</div>
</div>
<div class="site-wrapper">
{block:ifShowInfoButton}
<i class="fa fa-info-circle fa-3x" style="position:absolute; margin-left:0.4%; margin-top:0.4%; color:{color:Info Button Color};"></i>
{/block:ifShowInfoButton}
Change the col on the picture from md-2 to md-4.
Or change the col on the text from md-8 to md-10 (better)!
It works on a 12 grid system and currently it is only using 10 columns out of 12, which is why it appears to align to the left :)
You can also use offset.
papakia's answer is correct however you could also add an empty column in front of your image column that is col-md-2 this will sometimes help not throw off the scale of other items if they are already tuned to your liking.
I want to create input group with input + dropdown + button
http://jsfiddle.net/eRzDq/127/ This is my example
<div class="col-md-10">
<h3 id="btn-groups-single">Segmented dropdown groups</h3>
<div class="input-group">
<input type="text" class="form-control " placeholder="username"/>
<div class="input-group-btn">
<!--simple button-->
<button type="button" class="btn btn-default" data-toggle="dropdown">
<span class="caret"></span>
</button>
<button type="button" class="btn btn-default">Simple</button>
<!--dropdown button-->
<ul class="dropdown-menu">
<li>Dropdown link</li>
<li>Dropdown link</li>
</ul>
</div>
</div>
</div>
My problem is that i don't know how to make rounded corners for Simple-Button.
If i change order (swap simple button with dropdown button and add class .dropdown-toggle to dropdown) then behaviour is what i want.
So what class i need add to simple button to make it rounded on right? (I think add class .dropdown-toggle to simple button is not good solution)
if you have a local StyleSheet:
.btn { border-top-right-radius: 5px;
border-bottom-right-radius: 5px; }
Otherwise there is also a css class type usually used for footers that's called well and has border-radius,
it's oldschool Bootstrap (I usually avoid it since it's been abused) but you could recycle it for your needs
.well-sm or .well-small should do the trick
I have two Bootstrap button dropdown menus. How to I prevent the menus from wrapping to two lines? I can control the width of the menus with span classes, but the code acts as if there's still more invisible input field which forces the next drop-down menu to the next line. The even more core problem is that these dropdown inputs force a fixed amount of space between them in the next element to their right, regardless of their actual width.
Ultimately, I want them to behave similarly to input buttons, which align right next to each other. See screenshot.
<div class="row-fluid">
<!--- BASIC INFO --->
<div class="span12 well" style="height: 160px; background-color:">
<input type="text" class="input-small" placeholder="Eye Color">
<input type="text" class="input-mini" placeholder="Hair">
<div class="input-prepend">
<div class="btn-group">
<button class="btn dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>
<a>aa</a>
</li>
<li>
<a>aa</a>
</li>
<li>
<a>aa</a>
</li>
</ul>
</div>
<input class="span4" id="prependedDropdownButton" type="text" placeholder="Hair">
</div>
<div class="input-prepend">
<div class="btn-group">
<button class="btn dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>
<a>mm</a>
</li>
<li>
<a>mm</a>
</li>
<li>
<a>mm</a>
</li>
</ul>
</div>
<input class="span4" id="prependedDropdownButton" type="text" placeholder="Hair">
</div>
</div>
</div>
After more reading on the Bootstrap documentation and testing I notice that those kind of dropdowns that you want to use suck, they are not responsive. I think you are better off using <select> dropdowns.
Demo
http://jsfiddle.net/sulfureous/X8hdg/
HTML
<div class="row-fluid">
<div class="well clearfix">
<div class="row-fluid">
<div class="span3">
<input type="text" class="span12" placeholder="Eye Color">
</div><!--.span3-->
<div class="span3">
<input type="text" class="span12" placeholder="Hair">
</div><!--.span3-->
<div class="span3">
<select class="span12">
<option>Hair</option>
<option>Black</option>
<option>Blonde</option>
</select>
</div><!--.span3-->
<div class="span3">
<select class="span12">
<option>Race</option>
<option>Race 01</option>
<option>Race 02</option>
</select>
</div><!--.span3-->
</div><!--.row-fluid-->
</div><!--.well .clearfix-->
</div><!--.row-fluid-->
So I guess this is an alternate solution, I cleaned up the code indentation, commenting and what not and divided the spans in a way that I feel would make sense for that kind of responsive menu.
Notice I added clearfix, removed the inline style and the height.
Let me know if this solution is what you expected, otherwise with the other kind of dropdown you want you use it's doable but you will need to hack quite a bit, if it was easy the guys at Twitter Bootstrap would have made that element responsive from the get go.
Cheers.