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>
Related
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>
See the image above - I have Bootstrap dropdowns on the left, and buttons on the right. They're nicely aligned, but I'd like to move the pagination up so it's in between them to make better use of the space. Now currently the pagination code is further down, but if I move it between the dropdowns and buttons, it causes what you see in the second image. How can I have everything aligned?
Bootiply here: http://www.bootply.com/5Ufnpj317Z
EDIT:
please find attached images and do changes as per red area.
I've rearranged a fair bit of your code, summarised as follows:
introduced bootstrap container and rows
removed panel-body class
removed pull-right class from the buttons on the right
added test.css for some custom adjustments
fixed indenting
It looks ok an a wide screen, but elements will stack on top of each other on smaller screens.
/*test.css*/
#dropdownMenu1-div{
display:inline;
}
#dropdownMenu2-div{
display:inline;
}
.pagination{
margin:0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<html>
<head>
<link rel="stylesheet" href="bootstrap.css">
<link rel="stylesheet" href="test.css">
</head>
<body>
<h2 class="text-center">Browse</h2>
<hr class="no-bottom-pad">
<div class="container">
<div class="row">
<div class="col-xs-3">
<div class="dropdown inline-control" id="dropdownMenu1-div"">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
Location:
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu2">
<li>all</li>
<li class="divider"></li>
<li>London Waterloo</li>
<li>London Waterloo 3F workshop</li>
<li>London Waterloo comms room</li>
</ul>
</div>
<div class="dropdown inline-control" id="dropdownMenu2-div">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
Type:
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu2">
<li>all</li>
<li class="divider"></li>
<li>Laptop</li><li>Chromebook</li>
<li class="divider"></li>
<li>HP</li>
<li>Lenovo</li>
<li>Toshiba</li>
<li class="divider"></li>
<li>HP Brilliance 5000</li>
<li>Lenovo B50-70</li>
<li>Toshiba Portege R930</li>
</ul>
</div>
</div>
<div class="col-xs-2" id="page-numbers">
<!-- <p class="no-bottom-pad">136 laptops</p> -->
<ul class="pagination">
<li class="active">1</li>
<li>2</li>
<li>3</li>
</ul>
</div>
<div class="col-xs-7">
<a href="#" id="add-laptop-btn" class="btn btn-default" onclick="laptop_modal('new')">
Add Laptop
</a>
<input id="add-multiple-input" class="btn btn-default less-right-pad" type="number" min="0" max="50">
<a href="#" id="add-multiple-btn" class="btn btn-default less-right-pad disabled" onclick="addMultiple();">
Add Multiple ->
</a>
<input id="earmark-multiple-input" class="btn btn-default less-right-pad" type="number" min="0" max="50">
<a href="#" id="earmark-multiple-btn" class="btn btn-default less-right-pad disabled" onclick="addMultiple();">
Earmark Multiple ->
</a>
</div>
</div>
</div>
</body>
</html>
I'm kinda new to HTML/CSS, and I'm trying to create a page with a login dropdown, but for some reason there's no padding on the right side of it. How can I fix it?
I wasn't able to find a solution.
<div class="navbar navbar-fixed-top navbar-default">
<div class="navbar-header"><a class="navbar-brand">My Site</a>
<a class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="glyphicon glyphicon-bar"></span>
<span class="glyphicon glyphicon-bar"></span>
<span class="glyphicon glyphicon-bar"></span>
</a>
</div>
<div class="container">
<div class="navbar-collapse">
<ul class="nav pull-right navbar-nav">
<li>Sign Up
</li>
<li class="divider-vertical"></li>
<li class="dropdown"> <a class="dropdown-toggle" href="#" data-toggle="dropdown">Sign In <strong class="caret"></strong></a>
<div class="dropdown-menu" style="padding: 10px;min-width:240px;">
Login via
<div class="social-buttons">
<i class="fa fa-facebook"></i> Facebook
</div>
or
<form action="[YOUR ACTION]" method="post" role="form" class="form-horizontal">
<input class="form-control" id="inputEmail1" placeholder="Email" type="email" style="margin-bottom:.5em">
<input class="form-control" id="inputPassword1" placeholder="Password" type="password" style="margin-bottom:.5em">
<div class="checkbox">
<label>
<input type="checkbox">Remember me</label>
</div>
<input class="btn btn-primary" style="margin-top:.75em;width: 100%; height: 32px; font-size: 13px;" type="submit" name="commit" value="Sign In">
</form>
</div>
</li>
</ul>
</div>
</div>
</div>
As Bootstrap Documentation says, sometimes you will need to place your dropdown container in a different position, for those cases you need to add the dropdown-menu-right class like so:
<div class="dropdown-menu dropdown-menu-right" style="padding: 10px;min-width:240px;">
Here's a JSFiddle with the example working:
JSFiddle
Your HTML structure should be changed to reflect the base Bootstrap classes. Pull-right isn't respected in the way you're using it, use navbar-right instead. Check the Docs to see the options you have by default.
*Also this class doesn't exist > <span class="glyphicon glyphicon-bar"></span>
See working example Snippet.
.navbar .dropdown-menu-fb {
padding: 10px;
min-width: 240px;
}
.navbar .navbar-toggle {
padding: 5px 10px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="navbar navbar-fixed-top navbar-default">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-nav" aria-expanded="false"> <i class="fa fa-bars"></i>
</button>My Site
</div>
<div class="collapse navbar-collapse" id="bs-nav">
<ul class="nav navbar-nav navbar-right">
<li>Sign Up
</li>
<li class="dropdown"> <a class="dropdown-toggle" href="#" data-toggle="dropdown">Sign In <span class="caret"></span></a>
<ul class="dropdown-menu dropdown-menu-fb">
<li class="btn btn-default navbar-btn btn-block"> <i class="fa fa-facebook"></i> Login via Facebook
</li>
<li>
<form action="[YOUR ACTION]" method="post" role="form">
<p class="text-center">or Sign Up</p>
<div class="form-group">
<input class="form-control" id="inputEmail1" placeholder="Email" type="email">
</div>
<div class="form-group">
<input class="form-control" id="inputPassword1" placeholder="Password" type="password">
</div>
<div class="form-group">
<div class="checkbox">
<label>
<input type="checkbox">Remember me</label>
</div>
</div>
<div class="form-group">
<input class="btn btn-primary navbar-btn btn-block" type="submit" name="commit" value="Sign In">
</div>
</form>
</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
The container is too big and it go out of the screen?
Work on min-width and let container stay inside the viewport, than focus on padding.
<div class="dropdown-menu" style="padding: 10px;min-width:200px;">
probably you will have to work on dropdown-menu to fix it, we need the css code
I'm trying to do seach box like this:
What's the best way of doing it with bootstrap?.
I was playing with inline form and input group dropdown list, but I have problems with text input width, as it's not fills out whole page width.
http://www.bootply.com/LRUm7PdeMN
How about checking the snippet..
Rest of styling you can do yourself..
.container {
padding-top: 50px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<div class="container">
<div class="row">
<div class="col-xs-12">
<div class="search-box">
<form class="form-inline">
<div class="form-group">
<div class="input-group">
<input type="text" class="form-control" aria-label="..." placeholder="Search ...">
<div class="input-group-btn">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">All categories <span class="caret"></span>
</button>
<ul class="dropdown-menu dropdown-menu-right">
<li>Wszystkie kategorie
</li>
<li>Another action
</li>
<li>Something else here
</li>
<li role="separator" class="divider"></li>
<li>Separated link
</li>
</ul>
<button type="submit" class="btn btn-default">
<i class="fa fa-search"></i>
</button>
</div>
<!-- /btn-group -->
</div>
<!-- /input-group -->
</div>
</form>
</div>
</div>
</div>
</div>
I am trying to create a a group of controls with bootstrap however it does not seem to be rendering properly, I have an example here: https://jsfiddle.net/brightertools/jxafnoyx/
Code:
<form id="form" name="form" action="" method="post">
<div class="container">
<div class="form-group">
<label class="control-label" for="SelectOption">Select an Option</label>
<div class="input-group">
<select id="SelectOption" name="SelectOption" class="form-control">
<option value="">(select your option)</option>
</select>
<div class="input-group-btn ">
<button type="button" class="btn btn-default glyphicon glyphicon-plus" style="margin-top:-1px;" id="AddButton"></button>
<button type="button" class="btn btn-default dropdown-toggle glyphicon glyphicon-cog" style="margin-top:-1px;" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" id="GroupDropdown"></button>
<ul class="dropdown-menu">
<li><a id="EditLink">Edit</a>
</li>
<li><a id="DeleteLink">Delete</a>
</li>
</ul> <span class="input-group-addon"><span class="validation-icon glyphicon glyphicon-asterisk"></span></span>
</div>
</div>
</div>
</div>
</form>
One can see that the addon is wrapping, I cannot seem to fix this issue.
Current rendering within jsfiddle:
As Onkar Deshpande mentioned correctly in his comment
"multiple form-controls in a single input group are not supported".
Input groups
Place one add-on or button on either side of an input. You may also place one on both sides of an input.
We do not support multiple add-ons on a single side.
We do not support multiple form-controls in a single input group.
But there is a little work around you could use to make this work.
Just make sure to move your input-group-addon out of the input-group-btn div.
To make this look correct you would have to also remove the border-radius on the .btn class.
.btn {
border-radius: 0 !important;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<form id="form" name="form" action="" method="post">
<div class="container">
<div class="form-group">
<label class="control-label" for="SelectOption">Select an Option</label>
<div class="input-group">
<select id="SelectOption" name="SelectOption" class="form-control">
<option value="">(select your option)</option>
</select>
<div class="input-group-btn ">
<button type="button" class="btn btn-default glyphicon glyphicon-plus" style="margin-top:-1px;" id="AdvertiserEditButton"></button>
<button type="button" class="btn btn-default dropdown-toggle glyphicon glyphicon-cog" style="margin-top:-1px;" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" id="AdvertiserDropdown"></button>
<ul class="dropdown-menu">
<li><a id="AdvertiserEditLink">Edit</a>
</li>
<li><a id="AdvertiserDeleteLink">Delete</a>
</li>
</ul>
</div>
<span class="input-group-addon"><span class="validation-icon glyphicon glyphicon-asterisk"></span></span>
</div>
</div>
</div>
</form>
You can try like this: Demo
<div class="input-group">
<select id="SelectOption" name="SelectOption" class="form-control">
<option value="">(select your option)</option>
</select>
<div class="input-group-btn">
<button type="button" class="btn btn-default "><i class="glyphicon glyphicon-plus"></i></button>
<button type="button" class="btn btn-default dropdown-toggle " data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" id="AdvertiserDropdown"><i class="glyphicon glyphicon-cog"></i></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>
<span class="input-group-addon validation-icon glyphicon glyphicon-asterisk"></span> </div>
<!-- /.input-group -->