How to center-align buttons inside <td>? - html

enter image description hereI have two button inside my and I need to align it in the center
<td align="center">
<form action="ReplyFound" method="post" class="pull-left">
<a class="btn btn-default "><em class="fa fa-pencil"></em></a>
</form>
<form action="DeleteMessage" method="post" class="pull-left">
<a class="btn btn-danger "><em class="fa fa-trash"></em></a>
</form>
</td>

Try:
display: block;
margin: auto;

Try This :
.divCenter {
width: 100%;
max-width: 960px;
margin: 0 auto;
text-align: center;
}
.pull-left {
display: inline-block;
margin: 5px;
background-color: #000;
color: #fff;
}
<div class="divCenter">
<td align="center">
<form action="ReplyFound" method="post" class="pull-left">
<a class="btn btn-default "><em class="fa fa-pencil">Button1</em></a>
</form>
<form action="DeleteMessage" method="post" class="pull-left">
<a class="btn btn-danger "><em class="fa fa-trash">Button2</em></a>
</form>
</td>
</div>

You can use following html for this
<td class="text-center">
<form action="ReplyFound" method="post" class="btn-block">
<a class="btn btn-default "><em class="fa fa-pencil"></em></a>
</form>
<form action="DeleteMessage" method="post" class="btn-block">
<a class="btn btn-danger "><em class="fa fa-trash"></em></a>
</form>
</td>

Missing closing tag </form>.
If you are not defining width when its width will be wrap content.
<table style="width:100%">
<tr>
<td align="center">
<form action="ReplyFound" method="post" class="pull-left">
<a class="btn btn-default ">Edit</a>
</form>
<form action="DeleteMessage" method="post" class="pull-left">
<a class="btn btn-danger ">Delete</a>
</form>
</td>
</tr>
</table>

You can use this
.centerBtn{
display:inline-block;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<table style="width:100%">
<tr>
<td align="center" >
<div class="centerBtn">
<form action="ReplyFound" method="post" class="pull-left">
<a class="btn btn-default "><em class="fa fa-pencil"></em></a>
</form>
<form action="DeleteMessage" method="post" class="pull-left">
<a class="btn btn-danger "><em class="fa fa-trash"></em></a>
</form>
</div>
</td>
</tr>
</table>

Related

form and div class on the same line

I have an html form and a div class. Both are represented by buttons and are appearing in different lines. (one below another). I want both the buttons to appear on the same line. How can I achieve this?
<div class="form">
<form method="POST" action="{% url 'mytab' %}">
{% csrf_token %}
<button type="submit" name="drilldown_filter" class="btn btn-primary btn-sm" onclick="myFunction()" disabled><i class="fa fa-arrow-circle-down"></i></button>
<input type="hidden" id="data" name="input name" value="">
</form>
</div>
<div class="button-group">
<button class="btn btn-primary btn-sm" onClick="javascript:history.go(-1);" disabled><i class="fa fa-angle-double-down"></i></button>
</div>
Thanks
use this style for both divs:
<style>
.form{
display: inline-block
}
.button-group{
display: inline-block
}
</style>
This should work.
include Style = "float:left" for form div.
<div class="form" style="float:left;">
<form method="POST" action="">
<button type="submit" name="drilldown_filter" class="btn btn-primary btn-sm" onclick="myFunction()" disabled><i class="fa fa-arrow-circle-down">sdfgsdfg</i></button>
<input type="hidden" id="data" name="input name" value="">
</form>
try this css:
.form,.button-group {
display: inline-block;
}
All you have to do is make div.both that will contain both those divs and put a display: flex on that div.both in the CSS.
<div class="both" >
<div class="form">
<form>
<button>uno</button>
</form>
</div>
<div class="button-group">
<button>dos</button>
</div>
</div>
CSS
div.both {
display: flex;
}
Just copy and paste this code
<div class="form" style="float: left;">
<form method="POST" action="{% url 'mytab' %}">
{% csrf_token %}
<button type="submit" name="drilldown_filter" class="btn btn-primary btn-sm" onclick="myFunction()" disabled><i class="fa fa-arrow-circle-down"></i></button>
<input type="hidden" id="data" name="input name" value="">
</form>

IMemoryCache without MVC

From this code, which takes data from a database, I extract the fields that interest me and show them to the video.
#foreach (var item in Model.ProductList)
{
<tr>
<td onclick="myFunction(this)" class="view-message dont-show"><h5>#item.Id</h5></td>
<td onclick="myFunction(this)" class="view-message"><h5>#item.Name</h5></td>
<td onclick="myFunction(this)"><h4 style="margin-top: 5px;"><span class="label label-success ">#item.Model</span></h4></td>
<td onclick="myFunction(this)" class="view-message text-left"><h5>#item.Price</h5></td>
<td>
<form method="post">
<span class="btn-group pull-right" style="margin-top: 5px">
<a class="btn btn-warning btn-xs" asp-page="/Product/Edit" asp-route-id="#item.Id" style="background-color: green; height: 29px; margin-top: -1px;">
<i class="glyphicon glyphicon-edit"></i>
</a>
<button type="submit" class="btn btn-danger btn-xs" asp-page-handler="Delete" asp-route-id="#item.Id" style="height: 27px; margin-top: 0px;"
onclick="return confirm('Are you sure to delete this product?');">
<i class="glyphicon glyphicon-remove"></i>
</button>
</span>
</form>
</td>
</tr>
}
Question: How can I enter this data in cache (IMemoryCache)?
I use Core 2.1 and I would like to avoid using MVC and then using "controllers".
Thanks in advance for your help.

Divide spacing in bootstrap group of buttons

How to get equal spacing in this group of buttons?
When I add pull-right to the class the search and plus buttons is set to below the search box.
<tr>
<th class="col-md-3">
<small>Firma</small>
<span class="glyphicon glyphicon-sort-by-alphabet glyph_sorting" aria-hidden="true"></span>
<span class="glyphicon glyphicon-sort-by-alphabet-alt glyph_sorting" aria-hidden="true"></span>
</th>
<th class="col-md-3"><small>Plaats</small></th>
<th class="col-md-3"><small>Telefoon</small></th>
<th class="col-md-3">
<form action="" method="post">
<div class="form-group col-xs-8">
<input type="text" class="form-control input-sm" placeholder="Search">
</div>
<button type="submit" class="btn btn-default btn-sm"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></button>
<button type="button" class="btn btn-sm"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></button>
</form>
</th>
</tr>
Edit based on comment:
Set parent container (form) to flexbox row, and center it's children elements horizontally with even space in-between with justify-content:space-between & vertically with align-items:center.
Override bootstrap's .form-control's padding & margin, which is whats causing the space async between buttons & the search input.
form {
display: flex;
flex-flow: row wrap;
justify-content: space-between;
align-items: center;
}
div.form-group {
padding: 0;
margin: 0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<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>
<table>
<tr>
<th class="col-md-3">
<small>Firma</small>
<span class="glyphicon glyphicon-sort-by-alphabet glyph_sorting" aria-hidden="true"></span>
<span class="glyphicon glyphicon-sort-by-alphabet-alt glyph_sorting" aria-hidden="true"></span>
</th>
<th class="col-md-3"><small>Plaats</small></th>
<th class="col-md-3"><small>Telefoon</small></th>
<th class="col-md-3">
<form action="" method="post">
<div class="form-group col-xs-8">
<input type="text" class="form-control input-sm" placeholder="Search">
</div>
<button type="submit" class="btn btn-default btn-sm"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></button>
<button type="button" class="btn btn-sm"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></button>
</form>
</th>
</tr>
</table>

Aligning buttons next to many inputs inside a row

This is part of a bigger table. I have three fields and each one should have a remove button aligned next to it.
The CSS I have alignes only the first button, and the other buttons are in the same position. How can I place the other two buttons next to their fields.
Thanks!
td .btn.aligned {
position: absolute;
margin-top: 7px;
float: right;
margin-left: 5px;
}
td input {
float: left;
margin-bottom: 10px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://use.fontawesome.com/a06b1c7829.js"></script>
<table id="tablaProveedores" class="table table-hover">
<thead class="thead-inverse">
<th>Phone numbers</th>
</thead>
<tbody>
<tr>
<td>
<input type="text" name="phone1_1" id="telefono1_1" class="form-control" disabled/>
<a title="Remove" class="btn btn-danger btn-xs aligned"><span class="fa fa-times"></span></a>
<input type="text" name="phone2_1" id="telefono2_1" class="form-control" disabled/>
<a title="Remove" class="btn btn-danger btn-xs aligned"><span class="fa fa-times"></span></a>
<input type="text" name="phone3_1" id="telefono3_1" class="form-control" disabled/>
<a title="Remove" class="btn btn-danger btn-xs aligned"><span class="fa fa-times"></span></a>
</tr>
</tbody>
</table>
Wrap them in <div>s. Giving them the class .row with the bootstrap framework will do everything you need.
td .btn.aligned {
position: absolute;
margin-top: 7px;
float: right;
margin-left: 5px;
}
td .lowered {
margin-top: 44px;
}
td input {
float: left;
margin-bottom: 10px;
}
.spacer {
padding-left: 30px !important;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://use.fontawesome.com/a06b1c7829.js"></script>
<table id="tablaProveedores" class="table table-hover">
<thead class="thead-inverse">
<th>Phone numbers</th>
</thead>
<tbody>
<tr>
<td>
<div class="row">
<input type="text" name="phone1_1" id="telefono1_1" class="form-control" disabled/>
<a title="Remove" class="btn btn-danger btn-xs aligned"><span class="fa fa-times">
</span>
</a>
</div>
<div class="row">
<input type="text" name="phone2_1" id="telefono2_1" class="form-control" disabled/>
<a title="Remove" class="btn btn-danger btn-xs aligned"><span class="fa fa-times">
</span>
</a>
</div>
<div class="row">
<input type="text" name="phone3_1" id="telefono3_1" class="form-control" disabled/>
<a title="Remove" class="btn btn-danger btn-xs aligned"><span class="fa fa-times">
</span>
</a>
</div>
</tr>
</tbody>
</table>
I was able to get this accomplished with a bit less code. I removed the absolute positioning and applied a max-width to the input and a float left instead of right to the buttons since they're in the same table-cell.
Check out the jsfiddle
td .btn.aligned {
margin-top: 7px;
float: left;
margin-left: 5px;
}
td input {
float: left;
margin-bottom: 10px;
max-width:80%;
}

How to remove empty space in a div element?

Here I am providing a screenshot and I outlined the area I wanted to collapse all the way to just right after the last blue buttom, touching it. I outlined the area I wanted to collapse in red. Is there a specific class that will let me do that?
Ty
code:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="container">
<div class="panel panel-primary col-md-6">
<div class="row">
<!-- Label -->
<button type="button" class="btn btn-info btn-xs btn-block" id='invoicelabel'><strong>Invoice CP</strong>
</button>
<!-- Invoice CP -->
<div class="btn-group btn-group-vertical col-md-3 test2">
<button class="btn btn-primary btn-sm" type="submit">Total Amount</button>
<button class="btn btn-primary btn-sm" type="submit">Duplicate</button>
<button class="btn btn-primary btn-sm" type="submit">Clear</button>
<button class="btn btn-primary btn-sm" type="submit">Currency</button>
<button class="btn btn-primary btn-sm" type="submit" disabled>.</button>
<button class="btn btn-primary btn-sm" type="submit" disabled>.</button>
</div>
<table class="table table-condensed">
<tbody class="col-md-10 test pull-right">
<tr>
<td class="default" width="20%">
<input type="text" class="btn btn-default btn-sm col-sm-12 floatright" placeholder="Pieces">
</td>
<td class="default" width="35%">
<input type="text" class="btn btn-default btn-sm col-sm-12 floatright" placeholder="Unit Price">
</td>
<td class="default" width="45%">
<input type="text" class="btn btn-default btn-sm col-sm-12 floatright" placeholder="Line Amount">
</td>
</tr>
<tr>
<td class="default" width="20%">
<input type="text" class="btn btn-default btn-sm col-sm-12 floatright" placeholder="Pieces">
</td>
<td class="default" width="35%">
<input type="text" class="btn btn-default btn-sm col-sm-12 floatright" placeholder="Unit Price">
</td>
<td class="default" width="45%">
<input type="text" class="btn btn-default btn-sm col-sm-12 floatright" placeholder="Line Amount">
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
Try checking the CSS height property of the .test or .test2. Probably it is set to a specific value. If you leave it blank, the area will fit to the content.