Clear gap between span and table - html

JSFiddle
I can't resolve the gap between a h2 tag and a table. Beside, if you look at my attached image, you will se that in the second table, the first row's width(header) is shorter than the rest, any help is greatly appreciated!
h2 and table css :
.tieudemien
{
line-height: 24px;
background-color: #80A5CE;
text-transform: uppercase;
color: #FFF;
font-weight: bold;
font-size: 12px;
width:498px;
margin-bottom: 0;
padding-bottom: 0;
margin-left:1px;
}
.tb {
width: 500px;
padding-top:0;
padding-bottom:0;
}

Padding issue:
table td {
padding: 0;
}
See it here: http://jsfiddle.net/uryeto61/4/

Here's result: http://jsfiddle.net/abruzzi/uryeto61/3/
You can just change the padding of class .tdkq and tddd below:
.tdkq, .tddd {
padding: 0;
}

demo - http://jsfiddle.net/victor_007/uryeto61/2/
add to table
cellpadding='0'

Try this -
table td{
padding: 0;
}

Set table td Padding 0
Try This:
body {} table,
th,
td,
tr {
border-collapse: collapse;
}
.tb {
width: 500px;
padding-top: 0;
padding-bottom: 0;
}
/*2 cell đầu tiên, xác định độ rộng*/
.tdkq {
width: 70%;
vertical-align: top;
}
.tddd {
width: 30%;
vertical-align: top;
}
/*bảng kết quả và đầu đuôi*/
.tbkq {
width: 100%;
word-wrap: break-word;
table-layout: fixed;
float: left;
margin-bottom: 0;
padding-bottom: 0;
border-right: 1px solid #CCC;
}
.tbdd {
width: 100%;
}
.tbdd td {
border-top: 1px solid #CCC;
border-bottom: 1px solid #CCC;
border-left: 1px solid #CCC;
border-right: 1px solid #CCC;
}
/*cột giải và kết quả của bảng kết quả*/
.trkq {
width: 100%;
}
.thkqgiai {
width: 20% !important;
text-align: center;
color: white;
background-color: #910000;
}
.thkqso {
width: 80% !important;
}
.tdkqgiai {
text-align: center;
background-color: #F9F9F9;
color: #910000;
}
.tdkqgiaidb {
text-align: center;
color: white;
background-color: #910000;
}
.tdkqso {
text-align: center;
word-wrap: break-word !important;
border-top: 1px solid #CCC;
}
.tdkqsodb {
text-align: center;
word-wrap: break-word !important;
color: red;
border-top: 1px solid #CCC;
}
/*cột đầu và đuôi của bảng đầu đuôi*/
.thdddau {
width: 30%;
color: white;
background-color: #910000;
}
.thddduoi {
width: 70%;
color: white;
background-color: #910000;
}
/*tiêu đề cho bảng kq*/
.tieudemien {
line-height: 24px;
background-color: #80A5CE;
text-transform: uppercase;
color: #FFF;
font-weight: bold;
font-size: 12px;
width: 500px;
margin-bottom: 0;
padding-bottom: 0;
margin-left: 1px;
}
.tieudecuoi {
background-color: #80A5CE;
text-transform: uppercase;
color: #FFF;
font-weight: bold;
font-size: 12px;
margin-bottom: 0;
padding-top: 4px;
padding-bottom: 0;
width: 300px !important;
}
.tdtieudecuoi {
text-align: right;
background-color: #80A5CE;
text-transform: uppercase;
color: #FFF;
font-weight: bold;
font-size: 12px;
}
table td {
padding: 0;
}
<h2 class="tieudemien"> Kết quả xổ số Miền Bắc ngày 02-11-2014</h2>
<table class="tb">
<tbody>
<tr>
<td class="tdkq">
<table class="tbkq">
<tbody>
<tr class="trkq">
<th class="thkqgiai">Giải</th>
<th class="thkqso">BTB</th>
</tr>
<tr>
<td class="tdkqgiai">Đặc biệt</td>
<td class="tdkqsodb">23411</td>
</tr>
<tr>
<td class="tdkqgiai">Giải nhất</td>
<td class="tdkqso">37428</td>
</tr>
<tr>
<td class="tdkqgiai">Giải nhì</td>
<td class="tdkqso">38460-75356</td>
</tr>
<tr>
<td class="tdkqgiai">Giải ba</td>
<td class="tdkqso">02055-66542-36814-52154-66881-20546</td>
</tr>
<tr>
<td class="tdkqgiai">Giải bốn</td>
<td class="tdkqso">6300-7736-6062-3408</td>
</tr>
<tr>
<td class="tdkqgiai">Giải năm</td>
<td class="tdkqso">0235-2078-1344-6340-4550-6337</td>
</tr>
<tr>
<td class="tdkqgiai">Giải sáu</td>
<td class="tdkqso">046-421-944</td>
</tr>
<tr>
<td class="tdkqgiai">Giải bảy</td>
<td class="tdkqso">88-98-24-21</td>
</tr>
<tr>
<td class="tdtieudecuoi"></td>
<td class="tdtieudecuoi">span</td>
</tr>
</tbody>
</table>
</td>
<td class="tddd">
<table class="tbdd">
<tbody>
<tr class="trkq">
<th class="thdddau">Đầu</th>
<th class="thddduoi">Đuôi</th>
</tr>
<tr>
<td class="tdkqgiai">0</td>
<td class="tdkqso">0,8</td>
</tr>
<tr>
<td class="tdkqgiai">1</td>
<td class="tdkqso">1,4</td>
</tr>
<tr>
<td class="tdkqgiai">2</td>
<td class="tdkqso">8,1,4,1</td>
</tr>
<tr>
<td class="tdkqgiai">3</td>
<td class="tdkqso">6,5,7</td>
</tr>
<tr>
<td class="tdkqgiai">4</td>
<td class="tdkqso">2,6,4,0,6,4</td>
</tr>
<tr>
<td class="tdkqgiai">5</td>
<td class="tdkqso">6,5,4,0</td>
</tr>
<tr>
<td class="tdkqgiai">6</td>
<td class="tdkqso">0,2</td>
</tr>
<tr>
<td class="tdkqgiai">7</td>
<td class="tdkqso">8</td>
</tr>
<tr>
<td class="tdkqgiai">8</td>
<td class="tdkqso">1,8</td>
</tr>
<tr>
<td class="tdkqgiai">9</td>
<td class="tdkqso">8</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>

Related

I can't change row's background color in table

I can't change rows' background-color; I'd like to have one row red.
Here is my code:
table.cennik-table {
font-size: 20px;
border: 3px solid #555555;
width: 80%;
height: auto;
text-align: center;
border-collapse: collapse;
margin: 0 auto;
}
table.cennik-table th {
font-size: 22px;
background-color: #888888;
}
table.cennik-table td {
padding: 0.7rem;
}
table.cennik-table tr.rowB {
background-color: red;
}
<div>
<table class="cennik-table">
<tr>
<th>Ilość wejść</th>
<th>Zajęcia grupowe</th>
<th>Treningi personalne</th>
</tr>
<tr class="rowB">
<td>1x tydzień</td>
<td>20zł</td>
<td rowspan="4">50zł</td>
</tr>
<tr class="rowA">
<td>2x tydzień</td>
<td>60zł</td>
</tr>
<tr class="rowB">
<td>3x tydzień</td>
<td>110zł</td>
</tr>
<tr class="rowA">
<td>OPEN</td>
<td>160zł</td>
</tr>
</table>
</div>
I'm a beginner so I could have made some simple mistakes.

Impossible to put an image next to the table using domPDF

I have the table shown below; what I want is to insert an image next to the table in my pdf view. I am using domPDF.
I try to use display inline-block but domPDF doesn't support display inline.
table {
width: 100%;
border-collapse: collapse;
border-spacing: 0;
margin-bottom: 20px;
}
table th,
table td {
padding: 20px;
background: #EEEEEE;
text-align: center;
border-bottom: 1px solid #FFFFFF;
}
table th {
white-space: nowrap;
font-weight: normal;
}
table td {
text-align: right;
}
table td h3 {
color: #ab5401;
font-size: 1.2em;
font-weight: normal;
margin: 0 0 0.2em 0;
}
table .no {
color: #FFFFFF;
font-size: 1.6em;
background: #ad9c82;
}
table .desc {
text-align: left;
}
table .total .total-div {
text-decoration: line-through;
}
table .total {
background: #ad9c82;
color: #FFFFFF;
}
table td.total {
font-size: 1.2em;
}
table tbody tr:last-child td {
border: none;
}
table tfoot td {
padding: 10px 20px;
background: #FFFFFF;
border-bottom: none;
font-size: 1.2em;
white-space: nowrap;
border-top: 1px solid #AAAAAA;
}
table tfoot tr:first-child td {
border-top: none;
}
table tfoot tr:last-child td {
color: #ab5401;
font-size: 1.4em;
border-top: 1px solid #ab5401;
}
table tfoot tr td:first-child {
border: none;
}
<table border="0" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th class="no">#</th>
<th class="desc">DESCRIPTION</th>
<th class="total">TOTAL</th>
</tr>
</thead>
<tbody>
<tr>
<td class="no">01</td>
<td class="desc">
<h3>Website Design</h3>Creating a recognizable design solution based on the company's existing visual identity</td>
<td class="total">$1,200.00</td>
</tr>
<tr>
<td class="no">02</td>
<td class="desc">
<h3>Website Development</h3>Developing a Content Management System-based Website</td>
<td class="total">$3,200.00</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="2"></td>
<td colspan="2">SUBTOTAL</td>
<td>$5,200.00</td>
</tr>
<tr>
<td colspan="2"></td>
<td colspan="2">TAX 25%</td>
<td>$1,300.00</td>
</tr>
<tr>
<td colspan="2"></td>
<td colspan="2">GRAND TOTAL</td>
<td>$6,500.00</td>
</tr>
</tfoot>
</table>
While the image for placeholder is the following:
<img src="https://picsum.photos/200" alt="Image example">
I tried to add it but it is always placed under the table, not next to it as I want.
Try Adding good old floats.
table {
width: 100%;
border-collapse: collapse;
border-spacing: 0;
margin-bottom: 20px;
}
table th,
table td {
padding: 20px;
background: #EEEEEE;
text-align: center;
border-bottom: 1px solid #FFFFFF;
}
table th {
white-space: nowrap;
font-weight: normal;
}
table td {
text-align: right;
}
table td h3 {
color: #ab5401;
font-size: 1.2em;
font-weight: normal;
margin: 0 0 0.2em 0;
}
table .no {
color: #FFFFFF;
font-size: 1.6em;
background: #ad9c82;
}
table .desc {
text-align: left;
}
table .total .total-div {
text-decoration: line-through;
}
table .total {
background: #ad9c82;
color: #FFFFFF;
}
table td.total {
font-size: 1.2em;
}
table tbody tr:last-child td {
border: none;
}
table tfoot td {
padding: 10px 20px;
background: #FFFFFF;
border-bottom: none;
font-size: 1.2em;
white-space: nowrap;
border-top: 1px solid #AAAAAA;
}
table tfoot tr:first-child td {
border-top: none;
}
table tfoot tr:last-child td {
color: #ab5401;
font-size: 1.4em;
border-top: 1px solid #ab5401;
}
table tfoot tr td:first-child {
border: none;
}
<div style="width: 65%;float:left;">
<table border="0" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th class="no">#</th>
<th class="desc">DESCRIPTION</th>
<th class="total">TOTAL</th>
</tr>
</thead>
<tbody>
<tr>
<td class="no">01</td>
<td class="desc">
<h3>Website Design</h3>Creating a recognizable design solution based on the company's existing visual identity</td>
<td class="total">$1,200.00</td>
</tr>
<tr>
<td class="no">02</td>
<td class="desc">
<h3>Website Development</h3>Developing a Content Management System-based Website</td>
<td class="total">$3,200.00</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="2"></td>
<td colspan="2">SUBTOTAL</td>
<td>$5,200.00</td>
</tr>
<tr>
<td colspan="2"></td>
<td colspan="2">TAX 25%</td>
<td>$1,300.00</td>
</tr>
<tr>
<td colspan="2"></td>
<td colspan="2">GRAND TOTAL</td>
<td>$6,500.00</td>
</tr>
</tfoot>
</table>
</div>
<div style="width: 30%;float:left;">
<img src="https://picsum.photos/200" alt="Image example" style="width: 100%;">
</div>

How to place image over this table and make the position responsive

I have placed the image but it breaks when we resize the window.
I want it in the center of the first column which is description below the email service.
I want it to remain in the center all the time.
I have given the td position relative and made the image absolute position. Its relative to the td................................
* {
font-family: sans-serif;
}
table{
width: 100%;
border: 1px solid #edf2fc;
border-collapse: collapse;
margin-top: 30px;
}
table th {
padding: 11px 6px 11px 6px;
word-break: break-all;
background: #413fa4;
color: #fff;
text-align: center;
}
tr td {
border: 1px solid #cbdaf1;
}
table tbody td {
text-align: center;
padding: 33px 0 33px 0;
word-break: break-all;
font-size: 18px;
}
tfoot tr td {
padding-top: 4px;
padding-bottom: 4px;
}
tfoot tr td:first-child{
padding-right: 22px;
}
.gray {
background-color: lightgray
}
<table width="100%">
<thead style="background-color: lightgray;">
<tr>
<th>Description</th>
<th>Cost</th>
</tr>
</thead>
<tbody>
<tr>
<td style="position: relative">Email Service
<img style="position: absolute; left: 300px; top: 70px;" src="https://image.shutterstock.com/image-vector/paid-thank-you-grunge-rubber-260nw-564254104.jpg"width=130px;>
</td>
<td align="center">1400.00</td>
</tr>
</tbody>
<tfoot>
<tr>
<td align="right">Subtotal</td>
<td align="center">1635.00</td>
</tr>
<tr>
<td align="right">Tax</td>
<td align="center">294.3</td>
</tr>
<tr>
<td align="right">Discount</td>
<td align="center">294.3</td>
</tr>
<tr>
<td align="right">Total</td>
<td align="center" class="gray">$ 1929.3</td>
</tr>
</tfoot>
</table>
Wrap the text and the image inside a div with a flex box property, and then you can center it as you like
* {
font-family: sans-serif;
}
table{
width: 100%;
border: 1px solid #edf2fc;
border-collapse: collapse;
margin-top: 30px;
}
table th {
padding: 11px 6px 11px 6px;
word-break: break-all;
background: #413fa4;
color: #fff;
text-align: center;
}
tr td {
border: 1px solid #cbdaf1;
}
table tbody td {
text-align: center;
padding: 33px 0 33px 0;
word-break: break-all;
font-size: 18px;
}
tfoot tr td {
padding-top: 4px;
padding-bottom: 4px;
}
tfoot tr td:first-child{
padding-right: 22px;
}
.gray {
background-color: lightgray
}
.flex-b {
display:flex;
align-items:center;
justify-content:center;
}
<table width="100%">
<thead style="background-color: lightgray;">
<tr>
<th>Description</th>
<th>Cost</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="flex-b">
<span>Email Service</span>
<img src="https://image.shutterstock.com/image-vector/paid-thank-you-grunge-rubber-260nw-564254104.jpg"width=130px;>
</div>
</td>
<td align="center">1400.00</td>
</tr>
</tbody>
<tfoot>
<tr>
<td align="right">Subtotal</td>
<td align="center">1635.00</td>
</tr>
<tr>
<td align="right">Tax</td>
<td align="center">294.3</td>
</tr>
<tr>
<td align="right">Discount</td>
<td align="center">294.3</td>
</tr>
<tr>
<td align="right">Total</td>
<td align="center" class="gray">$ 1929.3</td>
</tr>
</tfoot>
</table>

Unwanted table cell border [duplicate]

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.

CSS class selector not working but tag and class selector does

When I use a class selector to modify the width of an element it does not work. When I use a tag and class selector as in table.change-name it does work.
HTML:
<!-- start settings -->
<div class='settings'>
<h4>Account Settings</h4>
<table class='options'>
<tr>
<td class='name username'>Name</td>
<td class='value'>Robert Rocha</td>
<td class='edit'><a href='#'>Edit</a></td>
</tr>
<tr>
<td class='name email'>Email</td>
<td class='value'>tom#gmail.com</td>
<td class='edit'><a href='#'>Edit</a></td>
</tr>
<tr>
<td class='name pword' colspan='2'>Password</td>
<td class='edit'><a href='#'>Edit</a></td>
</tr>
<tr>
<td class='name remove-all' colspan='3'><a href='#'>Delete All Photos</a></td>
</tr>
<tr>
<td class='name remove-account' colspan='3'><a href='#'>Delete Account</a></td>
</tr>
</table>
<table class='change-name'>
<tr>
<td class='first'>First</td>
<td><input type='text' name='fname' class='fname'></td>
</tr>
<tr>
<td class='middle'>Middle</td>
<td><input type='text' name='mname' class='mname'></td>
</tr>
<tr>
<td class='last'>Last</td>
<td><input type='text' name='lname' class='lname'></td>
</tr>
<tr>
<td class='save'><a href='#'>Save</a></td>
<td class='cancel'><a href='#'>Cancel</a></td>
</tr>
</table>
</div>
<!-- end settings -->
CSS:
/* Settings */
.settings {
width: 650px;
margin: 0 auto;
padding: 1em;
}
.settings h4 {
padding: 1em 0;
letter-spacing: 1px;
border-bottom: 1px solid #cacece;
}
.settings table {
width: 100%;
font-size: 0.9em;
letter-spacing: 1px;
font-weight: 200;
table-layout: fixed;
}
.settings tr { border-bottom: 1px solid #cacece; }
.settings td { padding: 0.5em 0; }
.settings .edit { text-align: right; }
.settings .name { font-weight: bold; }
.settings .remove-all, .settings .remove-account { font-weight: 200; }
/* Change Name Table */
.change-name {
background: #cacece;
width: 300px;
}
.change-name tr { border: none; }
Result: https://jsfiddle.net/yy1mu2ze/
If I do the following:
table.change-name {
background: #cacece;
width: 300px;
}
I get: https://jsfiddle.net/yy1mu2ze/1/
Why is this?