I have a popover of bootstrap, which inside there is a div with "btn-group" style which supposed to open an actions menu (aria-haspopup="true").
The problem is that the actions menu opens outside the popover borders, and when i'm changing the position/display property it goes inside the popover but moves all the text.
This is the HBS file of the whole popover:
<h3 class="popover-title" style="font-weight: bold;">{{title}}
<div style="float: right; text-align:center;" class="btn-group">
<button id="{{id}}-actions-button" type="button" class="btn btn-action js-primary-row-action" data-index="-1">{{primaryAction.text}}</button>
<button type="button" class="btn btn-action dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li role="separator" class="divider"></li>
<li>Separated link</li>
</ul>
</div>
</h3>
<div class="row">
<div style="padding-top:15px;">
{{#each rows}}
<div style="padding-bottom: 20px;">
<div style="float: left; width: 50%;"><label class="label-preview">{{cell1.label}} </label><div>{{cell1.value}}</div></div>
<div style="float: right; width: 50%; text-align:left;"><label class="label-preview">{{cell2.label}} </label><div>{{cell2.value}}</div></div>
<div style="height: 40px;"></div>
</div>
{{/each}}
</div>
</div>
and this is how the actions popup opens:
This is how i open the popover:
this.popupElement.popover({
template: html,
placement: 'right',
viewport: viewport
});
How can I open the actions popup just below the arrow?
Update:
I tried position:absolute - not working and i also tried the next combination:
position: relative; display: inline;
and the result was (as you can see the fields inside the big popover are moving aside...):
Thanks.
Update 5.1:
current position:
Use position: absolute to place the dropdown over your popup.
<h3 class="popover-title" style="font-weight: bold;">{{title}}
<div style="float: right; text-align:center;" class="btn-group">
<button id="{{id}}-actions-button" type="button" class="btn btn-action js-primary-row-action" data-index="-1">{{primaryAction.text}}</button>
<button type="button" class="btn btn-action dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li role="separator" class="divider"></li>
<li>Separated link</li>
</ul>
</div>
</h3>
.dropdown-menu {
position: absolute:
top: 20px; // height of the top my-new-title container
}
.btn-group {
position: relative;
}
Related
I am new to front-end. I want to modify design of bootstrap dropdown button like this:
picture
Bootstrap dropdown code:
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
Dropdown
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li role="separator" class="divider"></li>
<li>Separated link</li>
</ul>
</div>
How can I modify it according to above picture?
see my code below or this fiddle for working demo
.dropdown-menu>li>a{
color: red;
padding: 3px 10px;
}
.dropdown-menu>li>a .fa{
margin-right: 5px;
}
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
Dropdown
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li><i class="fa fa-cog"></i>Action</li>
<li><i class="fa fa-cog"></i>Action</li>
<li><i class="fa fa-cog"></i>Action</li>
<li><i class="fa fa-cog"></i>Action</li>
<li><i class="fa fa-cog"></i>Action</li>
</ul>
</div>
There's many ways..
Create a new CSS class with your own style and then add the class to your default jquery dropdown
Overide jquery class
Ex for number 1:
Create new CSS class:
.newDropdown {
background-color: #ddd;
color: #fff
border: 1px solid #000
}
then add .newDropdown to your html
<ul class="dropdown-menu newDropdown" aria-labelledby="dropdownMenu1">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li role="separator" class="divider"></li>
<li>Separated link</li>
</ul>
Ex for number 2:
Just overide the class:
.dropdown-menu {
background-color: #777;
}
.dropdown-menu li {
padding: 10px
}
Or you can read this answer for reference (even they're using select): How to style a <select> dropdown with CSS only without JavaScript?
I am trying to make a bootstrap inline form like dropdown-input-button. I was able to do this, but how can I make 100% width of input tag? Code snippet below.
<div class="row">
<div class="col-md-12">
<div class="form-inline">
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Action <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>Action
</li>
<li>Another action
</li>
<li>Something else here
</li>
<li role="separator" class="divider"></li>
<li>Separated link
</li>
</ul>
</div>
<div class="form-group">
<input type="text" class="form-control " placeholder="Search">
</div>
<button type="submit" class="btn btn-default">Search</button>
</div>
</div>
</div>
Fiddle: https://jsfiddle.net/xt4zk62v/
You need to create a class and apply it to the parent div that adds a width to it and update the width on the input to 100%;
#media (min-width: 768px){
.form-inline .form-control {
display: inline-block;
width: 100%;
vertical-align: middle;
}
}
https://jsfiddle.net/t3xd3esq/4/
I am using a dropdown-menu to show the candidate options I can choose. And I also want an input to filter the options, so when I enter something, the dropdown-menu should also be shown. So I want to adjust the width of the dropdown-menu to be equal to the input. And how can I show it when the I enter something in the input?
The html I current use is:
<div class="input-group">
<input type="text" class="form-control" aria-label="...">
<div class="input-group-btn">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
</button>
<ul class="dropdown-menu dropdown-menu-right">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li role="separator" class="divider"></li>
<li>Separated link</li>
</ul>
</div><!-- /btn-group -->
Actually you are searching for some kind of suggestion search box with given selectable choices if I understood correctly.
See this thread:twitter bootstrap autocomplete dropdown / combobox with Knockoutjs
Solution suggestions: selectize.js or Select2
The aspect of automatically adjusting the dropdown's width to be equal to the input's width is hard to achieve because it would cut off some of your given choices (example: Input is only one character - Dropdown would only show first character of every choice). This can't be what you want to achieve.
possible solution:
$('.dropdown-menu').width($('.input-group').width());
.input-group{
width:33%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div class="input-group">
<input type="text" class="form-control" aria-label="...">
<div class="input-group-btn">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="caret"></span></button>
<ul class="dropdown-menu dropdown-menu-right">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li role="separator" class="divider"></li>
<li>Separated link</li>
</ul>
</div><!-- /btn-group -->
I added an image size 53x53 next to the word Dropdown in my bootstrap navbar. The height of the navbar is 85px. adding the image makes the height resize to 100px I need it to remain 85px
<img class="image_top" src="myimage.png">Dropdown<span class="caret"></span>
.image-top {
float: left;
display: inline-block;
margin-top: 7px;
margin-right: 18px;
margin-left: 0;
margin-bottom: 4px;
padding-right: 10px;
}
You ckecked https://getbootstrap.com/components/#dropdowns? Documentation is very good..Eventhough it doesn't have an example with image dropdown i think..
You want something like this?
<div class="dropdown">
<button style = "padding: 3px;"class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<span class="image_top"><img style = "max-width:20px; max-height: 20px;" src="myimage.png"></span>
Dropdown
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li role="separator" class="divider"></li>
<li>Separated link</li>
</ul>
</div>
I wonder if there exists or if there is a way to make a bootstrap button like the one here, but with the dropdown-toggle to the left. If I just alter the order in the html, then the buttons do show in correct order, but their surfaces do not "snap" right to be totally adjacent as a unified button entity.
Is this what you are looking to accomplish?
http://jsfiddle.net/SeanWessell/2mbsLkmw/
HTML:
<!-- Split button -->
<div class="btn-group btn-group-left">
<button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<button type="button" class="btn btn-danger">Action</button>
<ul class="dropdown-menu">
<li>Action
</li>
<li>Another action
</li>
<li>Something else here
</li>
<li role="separator" class="divider"></li>
<li>Separated link
</li>
</ul>
</div>
Add btn-group-left to the btn-group div.
The add this css to override bootstrap:
CSS:
.btn-group.btn-group-left .dropdown-toggle {
border-top-right-radius: 0px !important;
border-bottom-right-radius: 0px !important;
}
.btn-group.btn-group-left .dropdown-toggle+.btn {
border-top-right-radius: 4px !important;
border-bottom-right-radius: 4px !important;
}