Display division between columns in bootstrap table - html

I set a bootstrap table to display a cryptocurrency ticker and I would like to display a line in between separating columns, using the border properties I guess, but I don't know exactly how to set the right side borders of the cells visible, so they form the vertical lines along rows.
<!-- Bootstrap 5 -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<!-- HTML -->
<div className="table-responsive-l">
<table className="table table-borderless fw-lighter table-xxl">
<tbody>
<tr className="fs-5 row-bottom-margin" id="currency_labels">
<th>BTC</th>
<th>ETH</th>
<th>XRP</th>
<th>BCH</th>
<th>EOS</th>
<th>DOGE</th>
</tr>
</tbody>
<tbody>
<tr className="fs-5">
<th>$1.00</th>
<th>$2.00</th>
<th>$3.00</th>
<th>$4.00</th>
<th>$5.00</th>
<th>$6.00</th>
</tr>
</tbody>
<tbody>
<tr className="fs-6">
<th>+0.1%</th>
<th>-0.2%</th>
<th>+0.3%</th>
<th>-0.4%</th>
<th>+0.5%</th>
<th>-0.6%</th>
</tr>
</tbody>
</table>
</div>

Can you check the below snippet and let me know if something like this is what you are expecting?
th:not(:last-child) {
border-right: 1px solid #444;
}
table {
border-spacing: unset;
}
<div class="table-responsive-l">
<table className="table table-borderless fw-lighter table-xxl">
<tbody>
<tr className="fs-5 row-bottom-margin" id="currency_labels">
<th>BTC</th>
<th>ETH</th>
<th>XRP</th>
<th>BCH</th>
<th>EOS</th>
<th>DOGE</th>
</tr>
</tbody>
<tbody>
<tr className="fs-5">
<th>$1.00</th>
<th>$2.00</th>
<th>$3.00</th>
<th>$4.00</th>
<th>$5.00</th>
<th>$6.00</th>
</tr>
</tbody>
<tbody>
<tr className="fs-6">
<th>+0.1%</th>
<th>-0.2%</th>
<th>+0.3%</th>
<th>-0.4%</th>
<th>+0.5%</th>
<th>-0.6%</th>
</tr>
</tbody>
</table>
</div>
Have added border-spacing: unset; property to table in order to avoid the space between rows.

Related

how to set column width in table so the content adjust according to the width?

Here is the table
<div class="container">
<table class="table table-striped" id="sms_data">
<thead>
<tr>
<th class="message">Message</th>
<th>DELIVERED</th>
<th>UNDELIVERED</th>
<th>EXPIRED</th>
<th>REJECTED</th>
<th>TOTAL</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<!-- 160 character long message-->
</td>
<td> Number</td>
<td> Number</td>
<td> Number</td>
<td> Number</td>
<td> Number Total</td>
</tr>
</tbody>
</table>
</div>
I want the Message column to be around 20% width. So I tried this
th.message {
width: 20%;
}
But with this the content is over lapping on other columns...
I want the content in Message column to look like this
Message with 160
character around
Instead of this
Message of 160 characters long
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
Bootstrap is used to style all content.
Please help me how to do this? Any help is appreciated..
<style>
.table{
table-layout:fixed;
}
td.message{
overflow: hidden;
}
td, th{
white-space: initial !important;
}
</style>
This solved my issue

CSS: Changing color on text in specifc column - but not on that column header?

I have the following HTML table:
<div class="table">
<table id="carTable">
<tbody>
<tr>
<th>Car Number</th>
<th>owner</th>
</tr>
<!-- {{#each car}} -->
<tr>
<td>{{carNumber}}</td>
<td>{{owner}}</td>
</tr>
<!--{{/each}} -->
</tbody>
</table>
</div>
And associated CSS that changes colour of text in first column:
#carTable tr>:nth-child(1){
font-weight: bold;
color: #2d89ac;
}
The problem is that this is also changing the color on the table header of that column.
How can I stop it doing so?
You should put your column titles in a thead (table header) section.
Although there are exceptions, putting your column titles in the tbodyis not generally good practice. Having the column titles in a separate header section permits scrolling of the body of the table whilst keeping the column titles in view.
<table id="carTable">
<thead>
<tr>
<th>Car Number</th>
<th>owner</th>
</tr>
</thead>
<tbody>
<!-- {{#each car}} -->
<tr>
<td>{{carNumber}}</td>
<td>{{owner}}</td>
</tr>
<!--{{/each}} -->
</tbody>
</table>
Then you could add a tbody selector in your CSS rule.
#carTable tbody tr>:nth-child(1){
font-weight: bold;
color: #2d89ac;
}
You can use the :not() rule in css:
#carTable tr>:nth-child(1):not(th) {
font-weight: bold;
color: #2d89ac;
}
<div class="table">
<table id="carTable">
<tbody>
<tr>
<th>Car Number</th>
<th>owner</th>
</tr>
<!-- {{#each car}} -->
<tr>
<td>{{carNumber}}</td>
<td>{{owner}}</td>
</tr>
<!--{{/each}} -->
</tbody>
</table>
</div>

Bootstrap table inside other table | Fix the height of table

I have little problem in my web page. I use bootstrap 4 and in table box I set inside other table as in the picture below. How to make the height of table inside the same as the hieght of the box (td)?
html:
<table class="table table-bordered">
<tbody>
<tr>
<td>REVERT</td>
<td>
<table class="table" style="height: 100%">
<tbody>
<tr>
<td>Name</td>
<td>LONG TEXT</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
Browser:
Because the table have CSS attribute margin-bottom: 20px, you need to add an override CSS to remove this attribute:
<table class="table table-bordered">
<tbody>
<tr>
<td>REVERT</td>
<td>
<table class="table table-no-margin" style="height: 100%">
<tbody>
<tr>
<td>Name</td>
<td>LONG TEXT</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<style>
.table-no-margin { margin: 0 }
</style>
This is happening because your nested table has a margin-bottom of 1rem(default bootstrap css). override it that's it.
Working example
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<table class="table table-bordered">
<tbody>
<tr>
<td>REVERT</td>
<td>
<table class="table" style="height: 100%; margin-bottom:0px;">
<tbody>
<tr>
<td>Name</td>
<td>LONG TEXT</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
This question has been asked many times before, but I'll answer it specifically for your scenario. It's not an issue of removing padding/margins.
In order to get a 100% height table, it's container must also be 100% height. So in this case set the containing td to height: 100%...
Demo on Codeply
<td>REVERT</td>
<td style="padding:0;height: 100%;">
<table class="table" style="height: 100%">
<tbody>
<tr>
<td>Name</td>
<td>LONG TEXT</td>
</tr>
</tbody>
</table>
</td>

Add input to table without styles

I'm adding inputs to my table td, but I want to show it in the same way that a simple cell. Here is my code:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table id="table">
<thead>
<tr>
<td>Some Text</td>
</tr>
</thead>
<tbody id="Body">
<tr>
<td><input disabled style="with:100%;" value="data" /></td>
</tr>
</tbody>
</table>
In simple words I want to show it like text, instead of showing borders and background. I tried adding outline: none but nothing happen.
3 things that you need to do to fix the style:
Remove the border using border: none
Remove the background using background: none
Add color: initial to remove the grey-ish color coming from disabled input
Working code snippet:
input {
border: none;
background: none;
color: initial;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table id="table">
<thead>
<tr>
<td>Some Text</td>
</tr>
</thead>
<tbody id="Body">
<tr>
<td>
<input disabled style="with:100%;" value="data" />
</td>
</tr>
</tbody>
</table>

In Internet Explorer 7, text-align: right is not taking effect

Is there any way to make the header align towards right?
Tested in Internet Explorer 7 only.
<html>
<style type="text/css">
th {
text-align: left;
}
</style>
<body>
<table width="100%" border="1">
<thead>
<tr>
<th style="width: 250px;">Tag
<th style="width: 100px; text-align: right;">Duration
</tr>
</thead>
<tbody>
<tr>
<td > one
<td> two
</tr>
</tbody>
</table>
</body>
</html>
First, close your tags. You have a lot of invalid HTML here. Second, you're mixing the table width (100%) as a percentage and the cell widths (250px, 100px) as pixel widths. These two are not compatible. Choose either one or the other and keep it consistent throughout your table.
<table style="width:350px" border="1">
<thead>
<tr>
<th style="width:250px;">Tag</th>
<th style="width:100px; text-align:right;">Duration</th>
</tr>
</thead>
<tbody>
<tr>
<td>one</td>
<td>two</td>
</tr>
</tbody>
</table>
You aren't closing your TH tags (or your TD tags for that matter). Fix below:
<table width="100%" border="1">
<thead>
<tr>
<th style="width: 250px;">Tag</th>
<th style="width: 100px; text-align: right;">Duration</th>
</tr>
</thead>
<tbody>
<tr>
<td> one </td>
<td> two </td>
</tr>
</tbody>
</table>