I have the following code:
<div class="row">
<div class="col-md-2">
<div class="dropdown">
<button type="button" class="btn btn-bee-space-blue dropdown-toggle buttonWidth" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Generate Report <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" data-bind="foreach: { data: ReportExportTypes, as: 'exportType' }">
<li>
</li>
</ul>
</br>
</div>
</div>
<div class="col-md-offset-8 col-md-2">
<button class="btn btn-bee-grey buttonWidth pull-right BackToScorecard" data-bind="click: $root.BackToScorecard, tooltip: { title: 'Back to Scorecard' }">Back to Scorecard</button>
</div>
</div>
Which shows up correctly like this:
But when I add the following code:
<div class="col-md-1">
<button type="button" class="btn btn-bee-space-blue buttonWidth" data-bind="click: EmailPopup, tooltip: { title: 'Get report to your email' },
enable: ReportingEditEnabled"> Email Report</button>
</div>
It totally breaks all the alignment of my buttons, it shows up like this:
Here is the full code with the button in it:
<div class="row">
<div class="col-md-2">
<div class="dropdown">
<button type="button" class="btn btn-bee-space-blue dropdown-toggle buttonWidth" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Generate Report <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" data-bind="foreach: { data: ReportExportTypes, as: 'exportType' }">
<li></li>
</ul>
</br>
</div>
</div>
<div class="col-md-1">
<button type="button" class="btn btn-bee-space-blue buttonWidth" data-bind="click: EmailPopup, tooltip: { title: 'Get report to your email' },
enable: ReportingEditEnabled"> Email Report</button>
</div>
<div class="col-md-offset-8 col-md-2">
<button class="btn btn-bee-grey buttonWidth pull-right BackToScorecard" data-bind="click: $root.BackToScorecard, tooltip: { title: 'Back to Scorecard' }">Back to Scorecard</button>
</div>
</div>
I want my Generate Report, Email Report and Back to scorecard buttons all in the same row.
Try to set the offset for the last button to 7. The idea is that since there are 12 columns in a row and you have col-md-2 and col-md-1 (the buttons on the left), you have 9 columns remaining to the end of the row. And if the last button is 2 columns wide, 7 columns remain between it and the other two as offset.
<div class="row">
<div class="col-md-2">
<div class="dropdown">
<button type="button" class="btn btn-bee-space-blue dropdown-toggle buttonWidth" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
Generate Report <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" data-bind="foreach: { data: ReportExportTypes, as: 'exportType' }">
<li><a href="#"
data-bind="reportExportTypeText: exportType, click: $root.OnGenerateReportClick.bind($root, exportType)"></a>
</li>
</ul>
</br>
</div>
</div>
<div class="col-md-1">
<button type="button" class="btn btn-bee-space-blue buttonWidth" data-bind="click: EmailPopup, tooltip: { title: 'Get report to your email' },
enable: ReportingEditEnabled"> Email Report</button>
</div>
<div class="col-md-offset-7 col-md-2">
<button class="btn btn-bee-grey buttonWidth pull-right BackToScorecard" data-bind="click: $root.BackToScorecard, tooltip: { title: 'Back to Scorecard' }">Back to Scorecard</button>
</div>
</div>
Related
I can't figure out how to translate this from Bs3 to Bootstrap 4:
<!--Site-->
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">Site</span>
<input type="search" name="searchBy" id="searchBy" class="form-control" placeholder="Suchbegriff eingeben"/>
<div class="input-group-btn">
<div class="btn-group">
<button class="btn btn-default dropdown-toggle dropdown-button" type="button" data-toggle="dropdown">
<span>Search By</span> <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li><</li>
<li>></li>
</ul>
</div>
</div>
</div>
</div>
I tried different ways, but all the time it looks so weird in bootstrap 4 oder even 5. Can u please help me with that?
I'm creating a page where the Next button in the page will redirect user to another tab / class in the same page.
I wanted a button that will link me to the next tab which is the Attachment tab using the #note as the reference.
What I have tried is I tried to put a link in the button but its not working. Is there any other way on how to do it? Other than put a link to it ?
<div class="col-md-12 text-right mt-4">
<button type="button" class="btn btn-md btn-primary" title="Add">Next</button>
</div>
<div class="default-tab">
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#home">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#next">Attachment</a>
</li>
</ul>
<div class="col-md-12 text-right mt-4">
<button type="button" class="btn btn-md btn-primary" title="Add">Next</button>
</div>
<div class="tab-pane fade" id="next">
<div class="pt-4">
<div class="col-lg-12">
......
</div>
</div>
</div>
</div>
I think you just need to add "#" in href.
Like this:
<div class="col-md-12 text-right mt-4">
<button type="button" class="btn btn-md btn-primary" title="Add">Next</button>
other than just adding an anchor tag, the possible way is to use javascript
HTML code :
<div class="col-md-12 text-right mt-4">
<button id="next" type="button" class="btn btn-md btn-primary" title="Add">
Next
</button>
</div>
here the javascript code,
const btn = document.querySelector('button#next');
const target = '#next';
btn.onclick = function () {
window.location.href = window.location.origin + target;
}
I have found my solution, below what I have tried
first I will add id="mytabs" in the ul
<ul class="nav nav-tabs" role="tablist" id="mytabs">
then at the button part I add on id="next"
<div class="col-md-12 text-right mt-4">
<button type="button" id="nextTab" class="btn btn-md btn-primary" title="Add">Next</button>
</div>
and lastly the javascript
<script>
$(function(){
$('#nextTab').click(function(e){
e.preventDefault();
$('#mytabs a[href="#next"]').tab('show');
})
})
</script>
This is my HTML
<div class="row">
<div class="col-md-6">
<div class="dropdown pull-left">
<button class="btn btn-xs btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<span class="caret"></span>
</button>
<ul class="dropdown-menu pull-left" aria-labelledby="dropdownMenu1">
<li>Edit</li>
<li>Delete</li>
</ul>
</div>
<span class="dark_gray_font pull-right">Ventes fleurs à 12%</span>
</div>
<div class="col-md-5">
<span class="dark_gray_font pull-right">25 <i class="fa fa-eur"></i></span>
<hr>
</div>
Edit
If select Edit option, I want to change
<span class="dark_gray_font pull-right">Ventes fleurs à 12%</span>
&
<span class="dark_gray_font pull-right">25 <i class="fa fa-eur"></i></span>
to input box
Delete
If select Delete option, I want to remove whole div (<div class="row">...</div>)
I tried to do it but my functions are wrong.
any help please.
Thank you.
Can be done by writing ng-click listeners on 'Edit' and 'Delete' element.And having a hidden input field each data record which will be shown when user press 'Edit' & the span element will be made hidden at that time.
In the below example if written makeItEditable as an edit listener & deleteIt as a delete listener.
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
$http.get("http://www.w3schools.com/angular/customers.php")
.then(function (response) {$scope.names = response.data.records;});
$scope.makeItEditable=function(index){
if($scope.currentEditableIndex!=null)
$scope.names[$scope.currentEditableIndex].editable=false;
$scope.names[index].editable=true;
$scope.currentEditableIndex=index;
}
$scope.deleteIt=function(index){
if($scope.currentEditableIndex!=null)
$scope.names[$scope.currentEditableIndex].editable=false;
$scope.names.splice(index,1);
$scope.currentEditableIndex=null;
}
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div ng-app="myApp" ng-controller="customersCtrl">
<div class="row" ng-repeat="x in names">
<div class="col-md-6">
<div class="dropdown pull-left">
<button class="btn btn-xs btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<span class="caret"></span>
</button>
<ul class="dropdown-menu pull-left" aria-labelledby="dropdownMenu1">
<li>Edit</li>
<li>Delete</li>
</ul>
</div>
<span ng-hide="x.editable" class="dark_gray_font pull-right">{{x.Name}}</span>
<input ng-show="x.editable" type='text' ng-model="x.Name"/>
</div>
<div class="col-md-5">
<span ng-hide="x.editable" class="dark_gray_font pull-right">{{x.Country}}<i class="fa fa-eur"></i></span>
<input ng-show="x.editable" type='text' ng-model="x.Country"/>
<hr>
</div>
</div>
You can have input fields adjacent to you span tags, which you can show/hide based on click of Edit and blur of the input field respectively.
angular.module('app', [])
.controller("test", function($scope) {
$scope.text1 = "Ventes fleurs à 12%";
$scope.text2 = "25";
$scope.edit = function() {
$scope.editText1 = true;
$scope.editText2 = true;
}
})
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js" ></script>
<script src="https://npmcdn.com/tether#1.2.4/dist/js/tether.min.js"> </script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" ></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.5/angular.min.js"></script>
<div ng-app="app" ng-controller="test">
<div class="row">
<div class="col-md-6">
<div class="dropdown pull-left">
<button class="btn btn-xs btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<span class="caret"></span>
</button>
<ul class="dropdown-menu pull-left" aria-labelledby="dropdownMenu1">
<li>Edit
</li>
<li>Delete
</li>
</ul>
</div>
<span class="dark_gray_font pull-right" ng-show="!editText1">{{text1}}</span>
<input type="text" class="dark_gray_font pull-right" ng-model="text1" ng-show="editText1" ng-blur="editText1=false" />
</div>
<div class="col-md-5">
<span class="dark_gray_font pull-right" ng-show="!editText2">{{text2}} <i class="fa fa-eur"></i>
</span>
<input type="text" class="dark_gray_font pull-right" ng-model="text2" ng-show="editText2" ng-blur="editText2=false" />
</div>
</div>
I'm trying to get a Bootstrap btn-group to work, with a few fixed elements and a btn in the middle that grows to fill out the entire thing.
JSFiddle of what I'm trying to do: http://jsfiddle.net/DTcHh/2988/
Basically the idea is I'm trying to get the 3 and 4 buttons to stick to the right, while the "Text here" element fills out the rest of the space. Menu sticks to the left.
I've tried putting btn-group-justified on the element I want to expand out but that makes it take up the entire width of the screen, whereas I want everything to be on one line.
HTML:
<div class="btn-group" role="group" aria-label="First group" style="width:100%; margin-right:-300px">
<div class="btn-group dropup" role="group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
Menu <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li>Edit Lead</li>
<li>Transfer Call</li>
</ul>
</div>
<div class="btn-group" role="group" aria-label="First group" style="width: 100%; margin-right:-320px">
<span class="btn btn-default" style="width:100%;">
Some text here
</span>
</div>
<button type="button" class="btn btn-default">3</button>
<button type="button" class="btn btn-default">4</button>
</div>
Any idea how I can achieve this?
Solved it.
Needed to set table-layout:auto on the parent group and add width:1% to the fixed size elements, width:100% to the expandable elements and add the class btn-group-justify to the parent group. Looks perfect now!
Fiddle: http://jsfiddle.net/DTcHh/2996/
try this
<div class="btn-group btn-group-justified" role="group" aria-label="First group" style="table-layout:auto">
<div class="btn-group dropup" role="group">
<a type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
Menu
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>Edit Lead</li>
<li>Transfer Call</li>
</ul>
</div>
<span class="btn btn-default" style="width: 100%;">Hey there</span>
<a type="button" class="btn btn-default">3</a>
<a type="button" class="btn btn-default">4</a>
</div>
This is my code: http://jsfiddle.net/52VtD/7462/
I'm trying to put my dropdown and buttons on the same line. But I can't do that because the dropdown is a div and stays on the line below. How can I put them on the same line?
<div class="panel panel-default">
<div class="panel-heading">
<input type="checkbox">
<button type="submit" class="btn btn-xs btn-default">Stage</button>
<button type="submit" class="btn btn-xs btn-default">Add Label</button>
<button type="submit" class="btn btn-xs btn-default">Send Message</button>
<button type="submit" class="btn btn-xs btn-default">Archive</button>
<div class="dropdown">
<button class="btn btn-xs btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown">
Assign to<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Unsorted <span class="badge">12</span></a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Another action <span class="badge">42</span></a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Something else here <span class="badge">42</span></a></li>
</ul>
</div>
</div>
Test
</div>
Never override or modify bootstrap base classes.. Always add new class or identity. You can do it like this :
Add new class "div-inline" to div with class dropdown..
Add this css
.div-inline{
display:inline-block;
}
JSFIddle : http://jsfiddle.net/rahulrulez/52VtD/7464/
As of bootstrap 4, you can change the dropdown line from:
<div class="dropdown">
to:
<div class="dropdown d-inline-block">
That will make all the buttons show up in one line.
Add this to your CSS:
.dropdown{
display: inline;
}
fiddle
I have just one drop down button and a few "normal" buttons. I am using bootstrap and did not want to get into editing CSS, so I resolved the issue as follows. It works, it is on one line, but the above solutions will work better if you have more than one dropdown on the same line.
I wrapped the whole thing (normal buttons and dropdown) into a <div class="row">. I then changed the <div class="dropdown> of the dropdown to <div class="dropdown col-sm-1" style="margin-right: 2%">. It did the trick.
My code looks like this:
<div class="row">
<spring:url value="/person/${person.id}/addaddress" var="addaddressUrl" />
<button class="btn btn-info"
onclick="location.href='${addaddressUrl}'">Add Address</button>
<spring:url value="/person/${person.id}/addphone" var="addphoneUrl" />
<button class="btn btn-primary"
onclick="location.href='${addphoneUrl}'">Add Phone</button>
<spring:url value="/person/${person.id}/addemail" var="addemailUrl" />
<button class="btn btn-success"
onclick="location.href='${addemailUrl}'">Add Email</button>
<spring:url value="/person/${person.id}/addpass" var="addpassUrl" />
<button class="btn btn-default"
onclick="location.href='${addpassUrl}'">Add Pass</button>
<spring:url value="/person/${person.id}/addnote" var="addnoteUrl" />
<button class="btn btn-warning"
onclick="location.href='${addnoteUrl}'">Add Note</button>
<div class="dropdown col-sm-1" style="margin-right: 2%">
<spring:url value="/person/${person.id}/role1" var="role1Url" />
<spring:url value="/person/${person.id}/role2" var="role2Url" />
<spring:url value="/person/${person.id}/role3" var="role3Url" />
<spring:url value="/person/${person.id}/role4" var="role4Url" />
<spring:url value="/person/${person.id}/role5" var="role5Url" />
<spring:url value="/person/${person.id}/role6" var="role6Url" />
<button class="btn btn-danger dropdown-toggle" type="button" data-toggle="dropdown"
>Add Role
<span class="caret"></span></button>
<ul class="dropdown-menu">
<li>role1</li>
<li>role2</li>
<li>role3</li>
<li>role4</li>
<li>role5</li>
<li>role6</li>
</ul>
</div>