Align two buttons (one of them in a form) in a table cell in Bootstrap 4 - css

I'm using Bootstrap 4 and I want to align two buttons inside a table column. The buttons are of the same size, but the second one is inside of a form.
I tried using the button group approach which almost solves the situation, but unfortunately there's a small gap between the buttons:
<td class="text-right">
<div class="btn-group" role="group">
<button type="button" class="btn btn-sm btn-secondary">Edit</button>
<form action="" method="POST">
<button type="button" class="btn btn-sm btn-danger">Delete</button>
</form>
</div>
</td>
What utility class can I use or any additional css in order to have the buttons aligned on the same level?
P.S. It doesn't have to be the button group, it can be any other technique as long as the buttons are on the same line.

Following the same strategy used to align columns in the bootstrap, its td can be of the row class, surrounded by items in the class col-md , col-lg, col-sm.
Try this:
HTML
<td class="text-right row">
<div class="btn-group" role="group">
<div class="col-md-6 custom">
<button type="button" class="btn btn-sm btn-secondary">Edit</button>
</div>
<div class="col-md-6 custom">
<form action="" method="POST">
<button type="button" class="btn btn-sm btn-danger">Delete</button>
</form>
</div>
</div>
</td>
Customize your column with a custom CSS
CSS
.custom {
padding-right: 5px;
padding-left: 5px;
}
https://jsfiddle.net/braulioti/aq9Laaew/160600/

Related

How to mix "well" and "button" together in bootstrap

My question is,I want to make the "well" and "button" of same size.
Here is my Html code:
<div class="well well-sm" id="well-color">
<button class="btn btn-default ">More Details</button>
</div>
Here is my CSS:
.well{
margin-right:800px;
}
Output
Could anyone help me on this
Use this
<div class="well well-sm" id="well-color">
<button class="btn btn-default well">More Details</button>
</div>
use space after 1 class and write another class name and it will work .

How to add space between right align bootstrap button?

I would like to add 3 spaces between two right align button. Is there any bootstrap solution for it without adding custom css?
I do this :
<div class="text-right">
<button class="btn-info btn">Log in</button>
<!-- Add 3 spaces between button -->
<button class="btn-info btn">Log Out </button>
</div>
Fiddle demo : http://jsfiddle.net/6816gq84/1/
You can add btn-toolbar class to the container div.
<div class="text-right btn-toolbar">
<button class="btn-info btn">Log in</button>
<button class="btn-info btn">Log Out </button>
</div>
Have a look here.
I do this rudimentary solution: How to add space between bootstrap buttons in same div?.
<div class="btn-group pull-right row">
<div class="col-md-3"><button class="btn btn-default" type="button">Clôturer</button></div>
<div class="col-md-1"></div>
<div class="col-md-3"><button class="btn btn-primary" type="button">Soumettre</button></div>
</div>
This also work fine for me:
<div style="display: flex ; justify-content: flex-end">
<button class="btn-info btn mr-3">Log in</button>
<button class="btn-info btn">Log Out </button>
</div>
I'm not sure any bootstrap solution already exists for what you want to do, but there are other way, depending what you mean by "custom css".
You can add a span balise for exemple and add an inline css defining the width to 3em (3 spaces). It's HTML/CSS but you don't modify the css of the button's class.
<div class="text-right">
<button class="btn-info btn">Log in</button>
<span style="width:3em;"> </span>
<button class="btn-info btn">Log Out </button>
</div>

Table inside form and both inside modal in Twitter Bootstrap does not display right, padding are missing

I have a situation here and perhaps solution is simple but I can't find a way out until now so I need some help.
I have this HTML code:
<div class="modal fade in" id="selectFabricante" tabindex="-1" role="dialog" aria-labelledby="selectFabricante" aria-hidden="false" data-backdrop="static" style="display: block; padding-right: 17px;"><div class="modal-backdrop fade in" style="height: 611px;"></div>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Cerrar</span></button>
<h4 class="modal-title">Seleccione uno o más fabricantes</h4>
</div>
<div class="modal-body">
<form id="fabForm" method="post" class="form-horizontal bv-form" novalidate="novalidate"><button type="submit" class="bv-hidden-submit" style="display: none; width: 0px; height: 0px;"></button>
<div class="form-group">
<div class="table-responsive">
<table class="table table-condensed">
<thead>
<tr>
<th><input type="checkbox" id="toggleChkSelFabricante" name="toggleChkSelFabricante"></th>
<th>Fabricante</th>
</tr>
</thead>
<tbody id="selFabricanteBody"><tr data-idproductosolicitud="1" data-id="1"><td><div class="checkbox"><label><input type="checkbox" name="fabLinkChoice[]" value="1"></label></div></td><td>Dist1</td><td>DR</td><td class="has_pais fabTd-1"><span id="14">México</span>, <span id="15">Nicaragua</span>, <span id="16">Panamá</span></td><td>1212212</td></tr><tr data-idproductosolicitud="1" data-id="1"><td><div class="checkbox"><label><input type="checkbox" name="fabLinkChoice[]" value="1"></label></div></td><td>Dist1</td><td>DR</td><td class="has_pais fabTd-1"><span id="14">México</span>, <span id="15">Nicaragua</span>, <span id="16">Panamá</span></td><td>1212212</td></tr></tbody>
</table>
</div>
</div>
<div>
<button type="button" class="btn btn-danger" data-dismiss="modal">Regresar</button>
<button type="submit" class="btn btn-primary" disabled="" id="btnAgregarSelFabricante"><i class="fa fa-save"></i> Agregar</button>
</div>
</form>
</div>
</div>
</div>
</div>
Which render as image below shows:
What can be wrong in that markup? I'm using latest version of Twitter Bootstrap. Any help? Advice?
Some clarifications:
I need the table inside the form because it's tabular data and semantic I think this is the right choice
I need the form because I'm using BootstrapValidator plugin and as says here in docs that the right markup, and I need to check at least one checkbox is checked before enable the submit button and allow send the form
Remove the element <div class="form-group"> and its end tag surrounding <div class="table-responsive">. That will fix the padding issue. You also have an issue with the checkbox class. If you remove the checkbox class from the <div> containing the checkbox it'll align properly.

Prevent bootstrap button groups from breaking

How can I prevent bootstrap button goups from breaking in to 2 lines when there is less space?
I am trying to use the below Bootstrap code:
<div class="btn-group" style=" width:100px ;">
<button type="button" class="btn btn-default" style=" width:30px;">-</button>
<input type="text" class="form-control" style="width:30px;">
<button type="button" class="btn btn-default" style=" width:30px;"> +</button>
</div>
And it looks like:
This is what worked for me, turn the group of buttons to a flex item (by default it does not wrap):
.btn-group {
display: flex;
}
I saw this here, and there are more options too:
https://github.com/twbs/bootstrap/issues/9939

Align button inline with bootsrap css

Here I have kept two button which should be inline but login facebook button get mis aligned. Why?
Fiddle : Fiddle
<div class="container">
<div class="row">
<input id="loginButton" class="btn btn-primary" type="button" value="Login | facebook" onclick="authUserX();" style="display: block;"></input>
<a href="./redirect.php">
<input id="loginTwitter" class="btn btn-primary" type="button" value="Login | Twitter "></input>
</a>
</div>
</div>

Resources