Align button to the right in td element - html

I have a <td> element with content and a button. The width of the content should be all except the width of the button which will be fixed. The button should be aligned to the right of the content. How can I achieve this, the following doesn't work:
<table border="1px">
<tr>
<td>
<div>
<div style="width: auto; overflow: auto;">
<span>
<form>
<textarea></textarea>
</form>
</span>
</div>
<div style="float: right; width: 32px;">
<button type="button" class="btn btn-primary">
Click
</button>
</div>
</div>
</td>
<td>Another cell</td>
</tr>
</table>

Use style="float: right;"
<table border="1px">
<tr>
<td>
<div style="display:inline-block">
<div style="display: inherit;width: calc(100% - 32px);overflow: auto;">
<span>
<form>
<textarea></textarea>
</form>
</span>
</div>
<div style="float: right; width: 32px;">
<button type="button" class="btn btn-primary" title="Select Financial Instrument" style="width:100%; word-wrap: break-word;">
Click
</button>
</div>
</div>
</td>
<td>Another cell</td>
</tr>
</table>

Based on Gerard's answer the following worked best for me:
<table border="1px">
<tr>
<td>
<div style="display: inline-flex; align-items: center; width: 100%;">
<div>
<span>
<form>
<textarea></textarea>
</form>
</span>
</div>
<div style="padding: 5px;">
<button type="button">
Click
</button>
</div>
</div>
</td>
<td>Another cell</td>
</tr>
</table>

Is this what you need?
<table border="1px">
<tr>
<td>
<div style="display: flex;">
<form>
<textarea></textarea>
</form>
<button type="button" class="btn btn-primary" title="Select Financial Instrument">
Click
</button>
</div>
</td>
<td>Another cell</td>
</tr>
</table>

you could decrease the font-size of the button so it fits inside the desired width (32px) you've set to the parent div
don't really understand your logic behind this html structure, but here is your solution
<table border="1px">
<tr>
<td>
<div>
<div style="width:calc(100% - 32px);overflow: auto;float:left">
<span>
<form>
<textarea></textarea>
</form>
</span>
</div>
<div style="float: right;">
<button type="button" class="btn btn-primary" style="width:32px;font-size:8px;" title="Select Financial Instrument">
Click
</button>
</div>
</div>
</td>
<td>Another cell</td>
</tr>
</table>

You can use a <table> and place the form in one <td> and the button in the other. Then you can fix the width of the <td> containing the button. This will force the first <td> to adjust its width according to the <table> width.
Check this jsFiddle, try to change the width of the main table and see how the <textarea> (and the <td>) adjust the width accordingly.
Update:
How about this, with no changes to your HTML structure:
* { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box }
<table border="1px" style="width: 450px">
<tr>
<td>
<div style="display: table; width: 100%">
<div style="display: table-row">
<div style="display: table-cell">
<span style="display: block; width: 100%">
<form style="display: block; width: 100%">
<textarea style="display: block; width: 100%"></textarea>
</form>
</span>
</div><!-- table-cell -->
<div style="display: table-cell; width: 32px;">
<button type="button" class="btn btn-primary">
Click
</button>
</div><!-- table-cell -->
</div><!-- table-row -->
</div><!-- table -->
</td>
<td>Another cell</td>
</tr>
</table>

Related

How to remove gap between two td

How to remove gap between two td ? I have tried some below solutions
from the Internet but none of them work. Attached the screenshot for
reference too. It will give clear idea of problem. The gap between two TD is very wide. How to reduce this Gap.
class="align-middle"
CELLSPACING=0
row-gap: 0;
class="views-field views-field-region views-align-center"
<app-header></app-header>
<section class="container">
<div class="row" style="background-color: white;">
<div class="col-xs-12 col-sm-8 col-md-4" >
<form action="/update/pricelist" method="POST" id="upload-file" enctype="multipart/form-data">
<h3>Import Pricelist</h3>
<hr>
<div class="wrapper-messages">
</div>
<br>
<input type="file" name="price_list" id="edit_price_list" (change)="ReadExcel($event)">
<div class="error-msg"></div>
<hr>
<div class="views-exposed-widget views-submit-button">
<button type="submit" class="btn btn-info form-submit icon-before submit-pricelist">
<span class="icon glyphicon glyphicon-ok" aria-hidden="true"></span>
Import
</button>
</div>
<br>
</form>
</div>
</div>
</section>
<!-- Table for excel -->
<div class="main-container container-fluid">
<div class="row">
<section id="block-views-exp-land-page" class="block block-views clearfix">
<form autocomplete="off" action="" method="post" id="views-exposed-form-land-page" accept-charset="UTF-8">
<div>
<section id="block-system-main" class="block block-system clearfix">
<div
class="view view-land view-id-land view-display-id-page table-checkbox-all view-dom-id-8d32f83bab6c36c396b926a7c7c35f7f">
</div>
<div class="view-content">
<div class="table-responsive" class="col-10" class="row align-items-center" class="col-md-12">
<table class="views-table cols-16 table table-hover table-0 table-0 table-0 neilsoft-region-table">
<thead class="neilsoft-region-table-head">
<tr>
<th class="views-field views-field-region views-align-center">
Autodesk Material Description
</th>
<th class="views-field views-field-php-4 views-align-center">
Autodesk SAP Material Description
</th>
<th class="views-field views-field-php-2 views-align-center">
Product Coming From
</th>
<th class="views-field views-field-php-2 views-align-center">
Media
</th>
</tr>
</thead>
</table>
</div>
</div>
<div class="view-content">
<div class="table-responsive" class="col-10" class="row align-items-center" class="col-md-12">
<table class="views-table cols-16 table table-hover table-0 table-0 table-0 neilsoft-region-table">
<thead class="neilsoft-region-table-head">
<tr *ngFor="let pricedata of ExcelData" class="align-middle">
<td>
{{pricedata.Autodesk_Material_Description}}
</td>
<td>
{{pricedata.Autodesk_SAP_Material_Description}}
</td>
<td>
{{pricedata.Product_Coming_From}}
</td>
<td>
{{pricedata.Media}}
</td>
</tr>
</thead>
</table>
</div>
</div>
</section>
</div>
</form>
</section>
</div>
</div>
<app-footer></app-footer>[enter image description here][1]
I suggest you looking for html table colspan (https://html.com/tables/rowspan-colspan/). With colspan you can merge two td cells. Take a look in the example below:
td {
width: 30px;
}
<table border="1">
<tr>
<td colspan="2">Merged</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
Perhaps border-collapse: collapse; is what you’re missing?
td {
background: red;
color: white;
padding: 0.5em;
}
.t1 {
margin-top: 2em;
border-collapse: collapse;
}
<table>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>4</td><td>5</td><td>6</td></tr>
</table>
<table class="t1">
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>4</td><td>5</td><td>6</td></tr>
</table>

HTML: Place table right aligned in other table cell

I want a table inside of a td of another table to be aligned at the right side.
<table style="width: 100%;">
<tr>
<td style="text-align:right;">
<table style="width: 200px; table-layout: fixed; background-color:blue">
<tr>
<td>
<input style="width:100%" type="button" value="OK" />
</td>
<td>
<input style="width:100%" type="button" value="Abbrechen" />
</td>
</tr>
</table>
</td>
</tr>
</table>
As you can see, the inner table is shown at the left side. How to accomplish?
Just add display: inline-table; to the inner table. Otherwise the text-align parameter won't apply, since it only applies to inline elements.
<table style="width: 100%">
<tr>
<td style="text-align:right;">
<table style="width: 200px; table-layout: fixed; background-color:blue; display: inline-table;">
<tr>
<td>
<input style="width:100%" type="button" value="OK" />
</td>
<td>
<input style="width:100%" type="button" value="Abbrechen" />
</td>
</tr>
</table>
</td>
</tr>
</table>

Height of all elements the same in Firefox but not Chrome

I would like to have all my boxes the same height
I used the CSS display: flex and it works fine for the first block but not his child
It works fine on Firefox but not on chrome
I found the row-eq-height class on getbootstrap but it isn't better on chrome
my page on chrome
my page on firefox
I have a div class row-eq-height then a col-md-4 and a panel
The panel height don't want to change
the code :
<div class="row-eq-height">
<div class="col-md-4">
<div class="panel panel-default no-padding server-box">
<!-- Default panel contents -->
<div class="panel-heading title-box">Regrowth</div>
<!-- Table -->
<table class="table server-table">
<tbody>
<tr>
<th>Adresse IP</th>
<td>#</td>
</tr>
<tr>
<th>Joueurs en ligne</th>
<td class="progress-bar-wrap">
<div>
<span style="width: 0%;"></span>
<span class="progress-bar-content">0
/50</span>
</div>
</td>
</tr>
<tr>
<th>Statut</th>
<td><img src="#" alt="status"></td>
</tr>
<tr>
<th>Ms/Tps</th>
<td class="good-tps">2.8 ms / 20 tps</td>
</tr>
<tr class="heads-tr">
<td class="heads-td">
<div class="heads">
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-default no-padding server-box">
<!-- Default panel contents -->
<div class="panel-heading title-box">InfinityHard</div>
<!-- Table -->
<table class="table server-table">
<tbody>
<tr>
<th>Adresse IP</th>
<td>#</td>
</tr>
<tr>
<th>Joueurs en ligne</th>
<td class="progress-bar-wrap">
<div>
<span style="width: 6%;"></span>
<span class="progress-bar-content">3
/50</span>
</div>
</td>
</tr>
<tr>
<th>Statut</th>
<td><img src="#" alt="status"></td>
</tr>
<tr>
<th>Ms/Tps</th>
<td class="#">7.1 ms / 20 tps</td>
</tr>
<tr class="heads-tr">
<td class="heads-td">
<div class="heads">
<img src="#" alt="Melkutus" data-toggle="tooltip"
data-trigger="hover" data-placement="bottom" title="Melkutus">
<img src="#"
data-toggle="tooltip" data-trigger="hover" data-placement="bottom"
title="FortunateTrollz">
<img src="#" alt="Asseo" data-toggle="tooltip"
data-trigger="hover" data-placement="bottom" title="Asseo">
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
and the css
.row-eq-height {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
}
.panel-container .server-box {
height: 100%;
}
thanks to people who will understand and answer me !

Table position (table goes down when it shouldn't)

Here is my code:
<form id="form1" style="height: 800px; width:1000px" >
<table style="width: 90%; height: 193;">
<tr>
<td class="style4">
<table style="width: 100%; height: 701px;">
<tr>
<td style="height: 587px; width: 629px;" colspan="4" >
<div id="tableTree" style="height:600px;">
<table style="width: 150px;">
<div id="treeboxbox_tree" style="width:280px; height:100%; ">
</div>
</table>
</div>
</td>
</tr>
<tr>
<td >
<input type="button" value="Add" id="btnAdd" onclick="return someMethod()" />
</td>
<td >
//other button
</td>
<td >
//other button
</td>
</tr>
</table>
</td>
<div>
<td>
<table width="100%" id="smth">
<div style="float:left"><%Html.RenderPartial("Something"); %></div>
</table>
</td>
</div>
</tr>
</table>
</form>
And smth is not shown until I click on a button. But since smth has very large height, the td which has style4 goes down, where the middle of smth is. It is very frustrating. How to resolve it?
I think you mean the vertical alignment is off in the td?
<td class="style4">
Change it to
<td class="style4" valign="top">
Or add to style4
vertical-align: top;
Not sure which version of html you are defining...

Put a div at the beginning of a table cell

I having trouble trying to put a div with the style catalog at the top of the cell of a table. I don't know why because in the next column, I have a div and it appears in the right place.
What am I doing wrong?
The code, live at jsFiddle:
<table id="tblButtonContainer" style="margin:0px;border:0px; border-collapse: collapse; border-spacing: 0;">
<tbody>
<tr>
<td style="">
<div class="ui-accordion-header ui-helper-reset ui-state-default topCatalog">
Categorias
</div>
</td>
<td>
<div class="ui-accordion-header ui-helper-reset ui-state-default">
<label style="float:left;color:#FFF">Buscar</label>
<input id="txtFinder" class="txtInput" type="text" value="Buscar" size="40">
<input id="btnFinder" type="button" value="Buscar" class="ui-button ui-widget ui-state-default ui-corner-all" role="button">
</div>
</td>
</tr>
<tr>
<td style="padding-right: 20px">
<div class="catalog ui-accordion-header ui-helper-reset ui-state-default" style="200px">
<ul class="menuCat">
<li>
<label class="formatText">Accesorios 4x4</label>
<span class="ui-icon ui-icon-triangle-1-e" style="float:right"></span>
</li>
<li>
<label class="formatText">Frenos y Pastillas</label>
<span class="ui-icon ui-icon-triangle-1-e" style="float:right"></span>
</li>
<li>
<label class="formatText">Tren Delantero</label>
<span class="ui-icon ui-icon-triangle-1-e" style="float:right"></span>
</li>
</ul>
</div>
</td>
<td>
<div id="catalogSearch" class="boxShadow">
<table id="tblCatalogSearch" class="centerTable" style="text-align:center">
<tbody>
<tr>
<td colspan="3">
<div style="margin:0;width:490px" class="ui-state-hover borders">
Elige el modelo de tu vehículo
</div>
<div style="height:20px"></div>
</td>
</tr>
<tr>
<td>
<label>Marca</label>
<select name="brand" id="brand">
<option value="0">Elige una Marca</option>
<option value="1">prueba</option>
</select>
</td>
<td>
<label>Modelo</label>
<select name="model" id="model" disabled="disabled"></select>
</td>
<td>
<label>Año</label>
<select name="year" id="year" disabled="disabled"></select>
</td>
</tr>
<tr><td><div style="height:20px"></div></td></tr>
<tr>
<td colspan="3">
<input name="btnSearch" id="btnSearch" value="Buscar" type="button" class="ui-button ui-widget ui-state-default ui-corner-all" role="button">
</td>
</tr>
</tbody>
</table>
</div>
<div id="results" class="boxShadow ui-corner-all borders" style="display: none; ">
<div style="margin:0;width:490px" class="ui-state-hover borders">
<span class="formatText" style="color:#373737;font-weight:bold;margin-left:20px">
Resultados de la Busqueda:
</span>
</div>
<table id="tblResult">
<tbody>
<tr></tr>
<tr><td>Uno</td></tr>
<tr><td>dos</td></tr>
</tbody>
</table>
</div>
</td>
</tr>
</tbody>
</table>
Note: I'm using jQuery-UI to help me with the styles I don't know if that is part of the problem.
Just add vertical-align:top; to your cell.
The default table cell behaviour is to vertically align to the centre. The second cell looks correct to you because it fills the whole cell. But it isn’t technically aligned to the top at all.
Use: #tblButtonContainer td {vertical-align: top;}.
Don't use inline styles!
You can also consider adding:
#tblButtonContainer td div {
display: table;
height: 100%;
width: 100%;
}
But I can't vouch for that in all browsers.