I'm new to CSS and SCSS. My issue seems very simple to fix but I'm not sure where to start.
I have three pages and they each have a table that look similar to this:
On the other pages I want the boxes (on the left) to go away, but I want to use the same CSS style sheet. Here is what the one of the other page's table look like:
I want the space on the right to go away and the word second to align all the way to the left.
Here is my scss:
section {
#include grid-row();
}
section p {
#include grid-column(12);
font-family: $font-stack;
font-size: 23px;
padding: 0;
margin: 0;
}
.button {
font-family: $font-stack;
color: #fff;
background-color: $secondary-color;
height: 27px;
text-align: center;
border-radius: 7px;
margin: 6px 0 5px 0;
padding: 5px 7px 5px 7px;
}
.button:hover {
background-color: $primary-color;
}
table {
#include grid-column(12);
padding: 0;
border-left: none;
border-right: none;
text-align:right;
border-collapse:separate;
border-spacing: 0 2px;
}
table {
tr {
background: #fff;
}
tr:hover {
background: #EBF7FC;
}
tr td {
padding:6px 8px;
}
tr td:first-child {
border-left: 3px solid #fff;
}
tr td:last-child {
border-right:3px solid #fff;
}
tr:hover td:first-child {
border-left: 3px solid $secondary-color;
}
tr:hover td:last-child {
border-right:3px solid $secondary-color;
}
}
.status {
color:#fff;
width: 33px;
padding: 5px 0;
text-align: center;
}
.statusRunning {
background-color: #5AD427;
#extend .status;
}
.statusQueued {
background-color: #A4E786;
#extend .status;
}
.statusIncomplete {
background-color: #FFCC00;
#extend .status;
}
.statusBlank {
width: 1px;
}
table tr td:nth-child(2) {
text-align:left;
}
.tightcell a {
margin-right:25px;
color: $secondary-color;
}
Here is my HTML for the page that is not working:
<section>
<p>Test Number 6 </p>
<table>
<tbody>
<tr>
<td class="statusBlank"></td>
<td>second</td>
<td>0000-00-00 00:00:00</td>
<td class="tightcell">Download
</tr>
<tr>
<td class="statusBlank"></td>
<td>second</td>
<td>0000-00-00 00:00:00</td>
<td class="tightcell">Download
</tr>
<tr>
<td class="statusBlank"></td>
<td>second</td>
<td>0000-00-00 00:00:00</td>
<td class="tightcell">Download
</tr>
<tr>
<td class="statusBlank"></td>
<td>second</td>
<td>0000-00-00 00:00:00</td>
<td class="tightcell">Download
</tr>
</tbody>
</table>
<p>Final Project </p>
<table>
<tbody>
<tr>
<td class="statusBlank"></td>
<td>second</td>
<td>0000-00-00 00:00:00</td>
<td class="tightcell">Download
</tr>
<tr>
<td class="statusBlank"></td>
<td>second</td>
<td>0000-00-00 00:00:00</td>
<td class="tightcell">Download
</tr>
</tbody>
</table>
</section>
The problem comes from this:
tr td {
padding:6px 8px;
}
No matter how small you try to make your cell, it will always take up at least 16px of space. Your best option is to just not have the empty cells in your markup at all if they're not serving an actual purpose.
Alternately, you could kill the padding:
.statusBlank {
padding: 0;
}
Related
My current table data is look like image1 how can make it to become the image2 the data look like card? I tried the border-radius CSS, but it still looks same nothing changes. I think the current data look very messy so I think change to card row data will become better...
table {
border: 1px solid #ccc;
width: 100%;
margin:0;
padding:0;
border-collapse: collapse;
border-spacing: 0;
}
table tr {
border: 2px solid #eee;
border-radius: 25px;
padding: 20px;
}
table th, table td {
padding: 10px;
text-align: center;
}
table th {
text-transform: uppercase;
font-size: 14px;
letter-spacing: 1px;
}
<table v-if="items.length >0">
<thead>
<th>{{$t('date')}}</th>
<th>{{$t('description')}}</th>
<th>{{$t('previousBalance')}}</th>
<th>{{$t('debit')}}</th>
<th>{{$t('credit')}}</th>
<th>{{$t('balance')}}</th>
</thead>
<tbody v-for="(item) in items" :key="item">
<tr>
<td :data-label="$t('date')">{{item.txDate}}</td>
<td :data-label="$t('description')"> {{item.txDesc}}</td>
<td :data-label="$t('previousBalance')">{{item.txBalBefore}}</td>
<td :data-label="$t('debit')" v-if="item.txAmount <=0">{{ item.txAmount }}</td>
<td :data-label="$t('debit')" v-else>0.00</td>
<td :data-label="$t('credit')" v-if="item.txAmount > 0">{{item.txAmount}}</td>
<td :data-label="$t('credit')" v-else>0.00</td>
<td :data-label="$t('balance')">{{item.txBalAfter}}</td>
</tr>
</tbody>
</table>
I can't try your snippets. but please take a look if this is what you are expecting.
body{
box-sizing: border-box
border: 1px solid #ddd;
}
table {
font-family: Arial, Helvetica, sans-serif;
border-collapse:separate;
border-spacing:0 15px;
width: 100%;
border: none
}
table td, #customers th {
padding: 20px;
}
table tr {background-color: #eaeefa;}
table th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #d9dff3;
}
td:first-child,
th:first-child {
border-radius: 10px 0 0 10px;
}
td:last-child,
th:last-child {
border-radius: 0 10px 10px 0;
}
<table id="customers">
<tr>
<th>Name</th>
<th>Age</th>
<th>Role</th>
</tr>
<tr>
<td>Temitope</td>
<td>12</td>
<td>Accountant</td>
</tr>
<tr>
<td>Alfred</td>
<td>23</td>
<td>Designer</td>
</tr>
<tr>
<td>Bello</td>
<td>14</td>
<td>Painter</td>
</tr>
<tr>
<td>John</td>
<td>25</td>
<td>Architect</td>
</tr>
<tr>
<td>James</td>
<td>10</td>
<td>Manager</td>
</tr>
</table>
Let me know if you have any questions
Is it possible to have the side borders of HTML tables like this:
A vertical line that is not connected to the top and bottom of the table.
You can try this :
body{
background:grey;
}
table, th, td {
border-top: 1px solid #fff;
border-bottom : 1px solid #fff;
border-collapse: collapse;
text-align:center;
padding:10px;
}
table
{
position: absolute ;
left:50%;
top:50%;
transform:translate(-50%,-50%);
border:2px solid #fff;
}
td
{
position:relative ;
}
td::after
{
content:'';
position:absolute ;
height:70%;
width:100%;
left:0;
top:7px;
border-left:3px solid #fff;
}
td:nth-child(1)::after
{
display:none;
}
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<table style="width:20%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<td>80</td>
</tr>
</table>
</body>
</html>
.table {
background-color: #272727;
width: 100%;
text-align: left;
border-collapse: collapse;
}
.table__body-row {
height: 41px;
border-bottom: 1px solid #000000;
}
.table__body-row.filled {
background: #191919;
}
.table__body-cell {
font-size: 14px;
color: #FFFFFF;
border: none;
}
.table__header {
background: #000000;
}
.table__header-row {
height: 40px;
}
.table__header-cell {
font-size: 12px;
font-weight: 400;
color: #FFFFFF;
text-align: left;
padding: 0 16px 0 16px;
}
.table__cell-body {
border-right: 1px solid #000000;
padding: 0 10px 0 10px;
min-height: 17px;
}
.table__body-cell:last-of-type .table__cell-body {
border-right: none;
}
<table class="table">
<thead class="table__header">
<tr class="table__header-row">
<th class="table__header-cell">
Header 1
</th>
<th class="table__header-cell">
Header 2
</th>
</tr>
</thead>
<tbody id="tableBody">
<tr class="table__body-row">
<td class="table__body-cell">
<div class="table__cell-body"></div>
</td>
<td class="table__body-cell">
<div class="table__cell-body"></div>
</td>
</tr>
</tbody>
</table>
This can be done using a nested div with a border. Please see snippet.
I'm stuck with a simple table design as i'm from backend I need a table like this
What I have right now
table {
border-collapse: collapse;
width: 100%;
}
tr {
border: none;
}
.first{
width: 40%;
font-family: Quasimoda;
font-size: 0.75em;
color: #1D1D1E;
}
.middle{
width: 60%;
font-family: Quasimoda;
font-size: 0.75em;
color: #1D1D1E;
}
.last{
width: 40%;
font-family: Quasimoda;
font-size: 0.75em;
color: #1D1D1E;
}
td {
border-bottom: 1px solid #ddd;
border-top: 1px solid #ddd;
padding: 10px;
}
<table>
<tr>
<td class="University">January</td>
<td class="middle ">the progress bar will be placed here </td>
<td class="last">870</td>
</tr>
<tr>
<td class="first">January</td>
<td class="middle ">the progress bar will be placed here </td>
<td class="last">560</td>
</tr>
</table>
Please help. I have tried with multiple html table attributes all gone in vain.
Set the thead tr element bottom border, and the right border of the .first element:
table {
border-collapse: collapse;
width: 100%;
}
th {
text-align: left;
border-bottom: 1px solid #ddd;
}
td {
padding: 10px;
font-family: Quasimoda;
font-size: 0.75em;
color: #1D1D1E;
}
.first {
border-right: 1px solid #ddd;
}
.middle {
width: 100%;
}
<table>
<thead>
<tr>
<th colspan="3">Unique values:</th>
</tr>
</thead>
<tbody>
<tr>
<td class="first">January</td>
<td class="middle ">the progress bar will be placed here </td>
<td class="last">870</td>
</tr>
<tr>
<td class="first">January</td>
<td class="middle ">the progress bar will be placed here </td>
<td class="last">560</td>
</tr>
</tbody>
</table>
Actually, your picture is not that clear.
I was not clear where you want border actually.
But I try to do this, Run the code snippet and have a look, and let me know if this works for you or not.
.colspan2border
{
border-collapse: collapse;
border-bottom: 1px solid red;
}
.rightBorder
{
border-collapse: collapse;
border-right: 1px solid red;
}
.pr-left1
{
padding-left: 1rem;
}
table
{
border-collapse: collapse;
}
tr
{
border: none;
}
<table>
<tr colspan="2" class='colspan2border'><td>Unique values:</td></tr>
<tr>
<td class="rightBorder pr-left1">University</td>
<td>870</td>
</tr>
<tr>
<td class="rightBorder pr-left1">Custom</td>
<td>560</td>
</tr>
</table>
This question already has answers here:
Removing unwanted table cell borders with CSS
(8 answers)
Closed 6 years ago.
table {
border: solid 1px #eee;
text-align: right;
}
tr,
td,
th {
padding: 0;
margin: 0;
border: none;
}
th,
td {
width: 90px;
height: 24px;
line-height: 24px;
padding: 0;
}
th {
background-color: #f4f4f4;
}
.first-col {
text-align: left;
}
<table class="satisfaction">
<tr>
<th class="first-col">Kepuasan</th>
<th>1 bulan</th>
<th>6 bulan</th>
<th>12 bulan</th>
</tr>
<tr>
<td class="first-col"><span><img class="svg emo emo-smile" src="img/icon/emoticon-happy.svg">Positif</span>
</td>
<td>9393</td>
<td>9393</td>
<td>9393</td>
</tr>
<tr>
<td class="first-col"><span><img class="svg emo emo-neutral" src="img/icon/emoticon-neutral.svg">Netral</span>
</td>
<td>93</td>
<td>93</td>
<td>93</td>
</tr>
<tr class="last-row">
<td class="first-col"><span><img class="svg emo emo-frown" src="img/icon/emoticon-sad.svg">Negatif</span>
</td>
<td>39</td>
<td>39</td>
<td>39</td>
</tr>
</table>
I made a table and I keep seeing this white separator on the first row.
I already done make all margin and padding to zero but it doesn't work. So far this is my styling
table {
border: solid 1px #eee;
text-align: right;
}
tr, td, th {
padding: 0;
margin: 0;
border: none;
}
th, td {
width: 90px;
height: 24px;
line-height: 24px;
padding: 0;
}
th {
background-color: #f4f4f4;
}
.first-col {
text-align: left;
}
Is there anything I'm missing out? Any help appreciated!
Looking at your posted CSS it seems likely that the 'border' is appearing because you haven't collapsed the cell-borders; so with that in mind I'd suggest you add the rule:
border-collapse: collapse;
to the CSS rules for the table element:
table {
border-collapse: collapse;
border: solid 1px #eee;
text-align: right;
}
table {
border-collapse: collapse;
border: solid 1px #eee;
text-align: right;
}
tr,
td,
th {
padding: 0;
margin: 0;
border: none;
}
th,
td {
width: 90px;
height: 24px;
line-height: 24px;
padding: 0;
}
th {
background-color: #f4f4f4;
}
.first-col {
text-align: left;
}
<table class="satisfaction">
<tr>
<th class="first-col">Kepuasan</th>
<th>1 bulan</th>
<th>6 bulan</th>
<th>12 bulan</th>
</tr>
<tr>
<td class="first-col"><span><img class="svg emo emo-smile" src="img/icon/emoticon-happy.svg">Positif</span>
</td>
<td>9393</td>
<td>9393</td>
<td>9393</td>
</tr>
<tr>
<td class="first-col"><span><img class="svg emo emo-neutral" src="img/icon/emoticon-neutral.svg">Netral</span>
</td>
<td>93</td>
<td>93</td>
<td>93</td>
</tr>
<tr class="last-row">
<td class="first-col"><span><img class="svg emo emo-frown" src="img/icon/emoticon-sad.svg">Negatif</span>
</td>
<td>39</td>
<td>39</td>
<td>39</td>
</tr>
</table>
References:
border-collapse.
I have a table in which I have to separate a row using border as in image below.
As you can see, Border separator is having a space left-right side and not fully touched to table border.
I tried giving padding,margin but nothing worked.
tr {
border-bottom: 1px solid blue;
padding: 10px; // not working
margin: 10px; // not working
}
https://jsfiddle.net/alpeshprajapati/s934Lpbx/
What is the way to achieve this?
CSS
table {
border: 1px solid black;
border-collapse: collapse;
}
thead {
background: black;
color: white;
}
th {
width: 100px;
}
tr {
float: left;
border-bottom: 1px solid blue;
width: 90%;
margin: 0 10px;
}
td{
width: 32%;
float: left;
}
Try this:
table {
border: 1px solid black;
border-collapse: collapse;
}
thead {
background: black;
color: white;
}
th {
width: 100px;
}
tr {
// border-bottom: 1px solid blue;
}
td{
padding:5px 10px;
}
.border{
background:skyblue;
width:100%;
height:2px;
}
<table>
<thead>
<th>Th1</th>
<th>Th2</th>
<th>Th3</th>
</thead>
<tbody>
<tr>
<td>TD1</td>
<td>TD2</td>
<td>TD3</td>
</tr>
<tr>
<td colspan="3">
<div class="border"></div>
</td>
</tr>
<tr>
<td>TD1</td>
<td>TD2</td>
<td>TD3</td>
</tr>
<tr>
<td colspan="3">
<div class="border"></div>
</td>
</tr>
<tr>
<td>TD1</td>
<td>TD2</td>
<td>TD3</td>
</tr>
</tbody>
</table>
To increase the length of the border you have to increase the width of the div that is containing it.