html table for a newsletter - html

I'm trying to reproduce this for a Newsletter, with the text and images centred.
This is what I have so far
I was trying to add the border-collapse: collapse; property and also to add border left and right but I'm stacked. If you have any suggestions how to create the vertical lines and cantered the text and images I would deeply appreciate any help.
<table class="outer-table-2">
<tr>
<td class="three-column">
<div class="section">
<table width="100%">
<tr>
<td class="inner-td">
<table class="content">
<tr>
<td class="text">
<p>01628531300</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<div class="section">
<table width="100%">
<tr>
<td class="inner-td">
<table class="content">
<tr>
<td>
<div id="callout">
<ul class="social">
<li><img src="facebook.png"></li>
<li><img src="twitter.png"></li>
<li><img src="linkedin.png"></li>
</ul>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<div class="section">
<table width="100%">
<tr>
<td class="inner-td">
<table class="content">
<tr>
<td class="text">
<p>www.cdvi.co.uk<p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<style>
.outer-table-2 {
width: 100%;
max-width: 670px;
margin: 12px auto;
border: 3px solid #00467f;
}
.three-column {
}
.three-column .section {
width: 100%;
max-width: 200px;
display: inline-block;
vertical-align: top;
background-color: #FFFFf;
}
.three-column .social {
width: 100%;
height: 10px;
margin: 0 0 5px 0;
}
.outer-table-2 p {
margin:10px 10px 10px 40px;
color: #00467f;
font-size: 12px;
font-weight: 1000 !important;
line-height: 10px;
}
.middle-table {
margin: auto;
padding-top: 10px;
}
.middle-table img{
width: 120px;
height: 80px;
}
</style>

I think you are massively over-complicating this. You only need one table to recreate a layout similar to your image.
table {
width: 100%;
border-collapse: collapse;
}
tr {
height: 60px;
}
td {
text-align: center;
}
.b-t {
border-top: 5px solid darkblue;
}
.b-l {
border-left: 5px solid darkblue;
}
.b-r {
border-right: 5px solid darkblue;
}
ul {
list-style: none;
margin: 0;
padding: 0;
}
li {
display: inline-block;
}
<table>
<tr>
<td class="b-t b-r">01628531300</td>
<td class="b-t">
<ul class="social">
<li><img src="facebook.png"></li>
<li><img src="twitter.png"></li>
<li><img src="linkedin.png"></li>
</ul>
</td>
<td class="b-t b-l">
www.cdvi.co.uk
</td>
</tr>
</table>

Related

Replicate Excel custom table using css + html

I want to replicate a table using CSS + HTML
So everything goes well until last part.
Table:
So I try:
#page {
background: #ffffff;
width: 878px;
margin: 0 auto;
margin-top: 40px;
display: block;
border: 1px solid #c4c7c7;
padding: 40px 40px 50px 40px;
position: relative;
z-index: 0;
}
.ship-table {
border-collapse: collapse;
}
.ship-table--title {
border-bottom: 3px solid;
border-top: 3px solid;
text-align: center;
background-color: #d3d3d3;
}
.ship-table--text_center {
text-align: center;
}
.ship-table--divider {
border-right: 3px solid;
border-left: 3px solid;
}
.ship-table--bottom {
border-bottom: 3px solid;
border-right: 3px solid;
}
.ship-table--image {
border-top: 3px solid;
border-right: 3px solid;
}
.ship-table--carrier {
background-color: #339933;
text-align: center;
}
.ship-table--due-box {
border: 3px solid;
}
.ship-table--dueDate {
background-color: #FFFF00;
}
.ship-table--dueDate_value {
font-size: 48px;
}
.ship-table--dueDate_field {
border: 3px solid;
border-color: red;
padding-bottom: 25px;
}
.ship-table--bol_value {
font-size: 28px;
}
<table class="ship-table">
<tbody>
<tr>
<td class="ship-table--title ship-table--divider">SHIP FROM</td>
<td class="ship-table--image" rowspan="2">pic here</td>
</tr>
<tr>
<td class="ship-table--divider">
{{ShipFromCompany}}
<br /> {{ShipFromAddressLineOne}}
<br /> {{ShipFromAddressLineTwo}}, {{ShipFromPostalCode}}
<br /> {{ShipFromAttn}}
<br /> {{ShipFromPhone}}
</td>
</tr>
<tr>
<td class="ship-table--title ship-table--divider">SHIP TO</td>
<td class="ship-table--title ship-table--divider">Carrier Name:</td>
</tr>
<tr>
<td class="ship-table--divider">
{{ShipToCompany}}
<br /> {{ShipToAddressLineOne}}
<br /> {{ShipToAddressLineTwo}}, {{ShipToPostalCode}}
<br /> {{ShipToAttn}}
<br /> {{ShipToPhone}}
</td>
<td class="ship-table--due-box">
<div class="ship-table--carrier ship-table--due-box ship-table--text_center">
{{ShipToCarrier}}
</div>
<div class="ship-table--dueDate ship-table--due-box ship-table--text_center">
DUE DATE:
</div>
<div class="ship-table--dueDate_value ship-table--dueDate_field ship-table--text_center">
{{ShipToDueDate}}
</div>
</td>
</tr>
<tr>
<td class="ship-table--title ship-table--divider">SHIPPER</td>
<td>
<div class="ship-table--title ship-table--divider">
BILL OF LADING NUMBER
</div>
<div class="ship-table--bol_value ship-table--text_center ship-table--divider">
{{BillOfLadingNumber}}
</div>
</td>
</tr>
<tr class="ship-table--bottom">
<td class="ship-table--divider">
{{ShipperCompany}}
<br /> {{ShipperAttn}}
<br /> {{ShipperAddressLineOne}}
<br /> {{ShipperAddressLineTwo}}
</td>
<td></td>
</tr>
</tbody>
</table>
How can I change nested borders to be part of the original colum, date be bigger than and the Bill Of ladding number at the bottom?
For nested borders I use border-colapse: colapse but it does not work.
Here is an easy solution. You can follow it.
#page {
background: #ffffff;
width: 878px;
margin: 0 auto;
margin-top: 40px;
display: block;
border: 1px solid #c4c7c7;
padding: 40px 40px 50px 40px;
position: relative;
z-index: 0;
}
.ship-table {
border-collapse: collapse;
width: 100%;
}
.ship-table tr, .ship-table td{
border: 1px solid #000;
}
.ship-table-table{
width: 100%;
}
.ship-table-table tr, .ship-table-table td{
border:0;
}
.ship-table--title {
border-bottom: 1px solid;
text-align: center;
background-color: #d3d3d3;
}
.ship-table--title-green{
border-top: 1px solid;
border-bottom: 1px solid;
text-align: center;
background-color: #339933;
}
.ship-table--title-yellow{
border-bottom: 1px solid;
text-align: center;
background-color: #FFFF00;
}
.ship-table--title-red{
border: 1px solid red !important;
text-align: center;
padding: 30px 0;
}
.ship-table--dueDate_value {
font-size: 48px;
text-align: center;
}
.ship-table--bol_value {
font-size: 28px;
text-align: center;
}
<div id="page">
<table class="ship-table" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
<table class="ship-table-table" cellpadding="0" cellspacing="0">
<tr>
<th class="ship-table--title">
SHIP FROM
</th>
</tr>
<tr>
<td>
{{ShipFromCompany}}
<br /> {{ShipFromAddressLineOne}}
<br /> {{ShipFromAddressLineTwo}}, {{ShipFromPostalCode}}
<br /> {{ShipFromAttn}}
<br /> {{ShipFromPhone}}
</td>
</tr>
</table>
</td>
<td>
pic here
</td>
</tr>
<tr>
<td valign="top">
<table class="ship-table-table" cellpadding="0" cellspacing="0">
<tr>
<th class="ship-table--title">
SHIP TO
</th>
</tr>
<tr>
<td>
{{ShipToCompany}}
<br /> {{ShipToAddressLineOne}}
<br /> {{ShipToAddressLineTwo}}, {{ShipToPostalCode}}
<br /> {{ShipToAttn}}
<br /> {{ShipToPhone}}
</td>
</tr>
</table>
</td>
<td valign="top" rowspan="2">
<table class="ship-table-table" cellpadding="0" cellspacing="0">
<tr>
<th class="ship-table--title">
Carrier Name:
</th>
</tr>
<tr>
<td>
CASC
</td>
</tr>
</table>
<table class="ship-table-table" cellpadding="0" cellspacing="0">
<tr>
<th class="ship-table--title-green">
{{ShipToCarrier}}
</th>
</tr>
<tr>
<th class="ship-table--title-yellow">
DUE DATE:
</th>
</tr>
<tr>
<td class="ship-table--title-red ship-table--dueDate_value">
{{ShipToDueDate}}
</td>
</tr>
</table>
<table class="ship-table-table" cellpadding="0" cellspacing="0">
<tr>
<th class="ship-table--title">
BILL OF LADING NUMBER
</th>
</tr>
<tr>
<td class="ship-table--bol_value">
{{BillOfLadingNumber}}
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top">
<table class="ship-table-table" cellpadding="0" cellspacing="0">
<tr>
<th class="ship-table--title">
SHIPPER
</th>
</tr>
<tr>
<td>
{{ShipperCompany}}
<br /> {{ShipperAttn}}
<br /> {{ShipperAddressLineOne}}
<br /> {{ShipperAddressLineTwo}}
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
There is no neat way to do this. You have to rely on css hacks to fix the borders. Also I couldn't fix bottom right corner cell
Here's a temporary fix to the nested border issue (except for the last column in the lastrow)
Changes have been highlighted with comments (Also note, I do not recommend this method, I am just giving you an idea of the nested border issue and tricks to overlap them)
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<style>
#page {
background: #ffffff;
width: 878px;
margin: 0 auto;
margin-top: 40px;
display: block;
border: 1px solid #c4c7c7;
padding: 40px 40px 50px 40px;
position: relative;
z-index: 0;
}
.ship-table {
border-collapse: collapse;
}
.ship-table--title {
border-bottom: 3px solid;
border-top: 3px solid;
text-align: center;
background-color: #d3d3d3;
}
.ship-table--text_center {
text-align: center;
}
.ship-table--divider {
border-right: 3px solid;
border-left: 3px solid;
}
.ship-table--bottom {
border-bottom: 3px solid;
border-right: 3px solid;
}
.ship-table--image {
border-top: 3px solid;
border-right: 3px solid;
}
.ship-table--carriership-table--carrier {
background-color: #339933;
text-align: center;
}
.ship-table--due-box {
border-right: 3px solid; /*changes */
}
.ship-table--carrier {
border-right:none; /* changes*/
}
.ship-table--dueDate {
background-color: #FFFF00;
border-right: none; /*changes*/
}
.ship-table--dueDate_value {
font-size: 48px;
/*changes*/
position: relative;
margin-left: -4px;
margin-right: -4px;
margin-bottom: -2px;
}
.ship-table--dueDate_field {
border: 3px solid;
border-color: red;
padding-bottom: 25px;
}
.ship-table--bol_value {
font-size: 28px; /*changes*/
border-left: none;
position: relative;
margin-right: -2px;
}
.table-border-fix { /* new class to fix the borders in bottom column*/
border: 3px solid;
position: relative;
margin-left: -4px;
margin-right: -2px;
border-top: none;
}
</style>
</head>
<body>
<table class="ship-table">
<tbody>
<tr>
<td class="ship-table--title ship-table--divider">SHIP FROM</td>
<td class="ship-table--image" rowspan="2">pic here</td>
</tr>
<tr>
<td class="ship-table--divider">
{{ShipFromCompany}}
<br /> {{ShipFromAddressLineOne}}
<br /> {{ShipFromAddressLineTwo}}, {{ShipFromPostalCode}}
<br /> {{ShipFromAttn}}
<br /> {{ShipFromPhone}}
</td>
</tr>
<tr>
<td class="ship-table--title ship-table--divider">SHIP TO</td>
<td class="ship-table--title ship-table--divider">Carrier Name:</td>
</tr>
<tr>
<td class="ship-table--divider">
{{ShipToCompany}}
<br /> {{ShipToAddressLineOne}}
<br /> {{ShipToAddressLineTwo}}, {{ShipToPostalCode}}
<br /> {{ShipToAttn}}
<br /> {{ShipToPhone}}
</td>
<td class="ship-table--due-box">
<div class="ship-table--carrier ship-table--due-box ship-table--text_center">
{{ShipToCarrier}}
</div>
<div class="ship-table--dueDate ship-table--due-box ship-table--text_center">
DUE DATE:
</div>
<div class="ship-table--dueDate_value ship-table--dueDate_field ship-table--text_center">
{{ShipToDueDate}}
</div>
</td>
</tr>
<tr>
<td class="ship-table--title ship-table--divider">SHIPPER</td>
<td>
<!-- introduced new class table-border-fix to below 2 divs-->
<div class="ship-table--title ship-table--divider table-border-fix">
BILL OF LADING NUMBER
</div>
<div class="ship-table--bol_value ship-table--text_center ship-table--divider">
{{BillOfLadingNumber}}
</div>
</td>
</tr>
<tr class="ship-table--bottom">
<td class="ship-table--divider">
{{ShipperCompany}}
<br /> {{ShipperAttn}}
<br /> {{ShipperAddressLineOne}}
<br /> {{ShipperAddressLineTwo}}
</td>
</body>
</html>
References: Nested divs: how can I get overlapping borders?

How to center tbody within a table while having text-align:left?

#present-container{
background-color: antiquewhite;
text-align: center;
}
#presentation{
display: inline-block;
text-align: center;
}
#tabela{
display: inline-block;
width: 40%;
margin: 10px;
padding: 25px;
border: 2px solid #e4d8ba;
border-radius: 8px;
border-collapse: collapse;
}
#tabela tbody {
}
#tabela th, td {
padding: 15px;
text-align: left;
border-top: 2px solid #e4d8ba;
}
.top{
border: none;
}
<div id="present-containter">
<div id="presentation">
<table id="tabela">
<tr><td class="top">Nearby</td><td class="top"><li>Beach: 500 meters (Pebble)</li><li>Restaurant: 1 km</li><li>Market: 200 meters</li></td></tr>
<tr><td>Included in price</td><td><li>Bedlinen including towels</li><li>Final Cleaning</li><li>Consumption costs</li></td></tr>
<tr><td>other</td><td><li>free WiFi</li><li>pets not allowed</li></td></tr>
</table>
</div>
</div>
Check this image:
How can I center the table body or table columns within the table while keeping text-align: left.
If I'm understanding correctly you're looking for something like this. Also went and cleaned up your syntax which wasn't valid in many ways but hope this helps, cheers.
#present-container {
border: 2px solid #e4d8ba;
border-radius: 8px;
background-color: antiquewhite;
margin: 0 auto;
}
#tabela {
padding: 25px;
border-collapse: collapse;
margin: 10px auto;
}
#tabela tr:not(:last-child) {
border-bottom: 2px solid #e4d8ba;
}
#tabela td {
padding: 15px;
}
<div id="present-container">
<table id="tabela">
<tbody>
<tr>
<td>
Nearby
</td>
<td>
<ul>
<li>Beach: 500 meters (Pebble)</li>
<li>Restaurant: 1 km</li>
<li>Market: 200 meters</li>
</ul>
</td>
</tr>
<tr>
<td>
Included in price
</td>
<td>
<ul>
<li>Bedlinen including towels</li>
<li>Final Cleaning</li>
<li>Consumption costs</li>
</ul>
</td>
</tr>
<tr>
<td>
other
</td>
<td>
<ul>
<li>free WiFi</li>
<li>pets not allowed</li>
</ul>
</td>
</tr>
</tbody>
</table>
</div>

Overflow method not working in html page.

I am working on an assignment for school which is designing an app with HTML. I am having trouble with the contents of the apps bleeding over at the bottom when you scroll down. I tried various options of the overflow method and nothing seems to work. I included the entire css and html. Thanks to anyone who takes the time to help me out!
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="CSS/reset.css">
<link rel="stylesheet" href="CSS/style.css">
<link href=https://fonts.googleapis.com/css?family='Roboto' rel='stylesheet'>
</head>
<body>
<div id="table-wrapper">
<div id="table-scroll">
<section class="container">
<nav>
<img src="images/status bar.png" width="360" height="24" alt=""/>
<div class="app-bar">
<table width="100%" border="0">
<tbody>
<tr>
<td class="ham-menu"><img src="images/menu.png" width="24" height="24" alt=""/></td>
<td class="title">Washington at State Station</td>
<td class="search-icon"><img src="images/search.png" width="24" height="24" alt=""/></td>
<td class="icon"><img src="images/menu-item.png" width="5" height="24" alt=""/></td>
</tr>
</tbody>
</table>
</div>
<div class="route-bar"><table width="100%" border="0">
<tbody>
<tr>
<td class="lines"><h2>Line</h2></td>
<td class="dest"><h2>Destination</h2></td>
<td class="times"><h2>Arrival</h2></td>
</tr>
</tbody>
</table>
</div>
</nav>
<section class="bus-list">
<div class="info">
<table width="100%" border="0">
<tbody>
<tr>
<td class="lines"><h1>124</h1></td>
<td class="dest"><h1>Eastbound</h1>
<h3>Navy Pier</h3></td>
<td class="times"><h1>5 Min</h1>
<h3>Freq. 10 min</h3>
</td>
</tr>
</tbody>
</table>
</div>
<div class="info">
<table width="100%" border="0">
<tbody>
<tr>
<td><h1>124</h1></td>
<td class="dest"><h1>Southbound</h1> <h3>Navy Pier</h3></td>
<td class="times"><h1>10 Min</h1>
<h3>Freq. 10 min</h3>
</td>
</tr>
</tbody>
</table>
</div>
<div class="info">
<table width="100%" border="0">
<tbody>
<tr>
<td><h1>J14</h1></td>
<td class="dest"><h1>Southbound</h1>
<h3>103rd/Stony Island</h3></td>
<td class="times"><h1>15 Min</h1>
<h3>Freq. 15 min</h3></td>
</tr>
</tbody>
</table>
</div>
<div class="info">
<table width="100%" border="0">
<tbody>
<tr>
<td class="lines"><h1>151</h1></td>
<td class="dest"><h1>Northbound</h1>
<h3>Devon/Clark</h3></td>
<td class="times"><h1>16 Min</h1>
<h3>Freq. 16 min</h3></td>
</tr>
</tbody>
</table>
</div>
<div class="info">
<table width="100%" border="0">
<tbody>
<tr>
<td class="lines"><h1>60</h1></td>
<td class="dest"><h1>Eastbound</h1>
<h3>Randolph/Harbor Dr</h3></td>
<td class="times"><h1>18 Min</h1>
<h3>Freq. 20 min</h3></td>
</tr>
</tbody>
</table>
</div>
<div class="info">
<table width="100%" border="0">
<tbody>
<tr>
<td class="lines"><h1>6X</h1></td>
<td class="dest"><h1>Reroute</h1>
<h3>Jackson Park Express</h3>
</td>
<td class="times"><h1>30 Min</h1>
<h3>Freq. N/A</h3></td>
</tr>
</tbody>
</table>
</div>
<div class="info">
<table width="100%" border="0">
<tbody>
<tr>
<td class="lines"><h1>4</h1></td>
<td class="dest"><h1>Out of Service</h1>
<h3>Cottage Grove</h3>
<h3>Resumes 12:10 am</h3></td>
<td class="alert">
</td>
</tr>
</tbody>
</table>
</div>
<div class="info">
<table width="100%" border="0">
<tbody>
<tr>
<td class="lines"><h1>20</h1></td>
<td class="dest"><h1>Out of Service</h1>
<h3>Madison</h3>
<h3>Resumes 12:10 am</h3></td>
</td>
<td class="alert">
</td>
</tr>
</tbody>
</table>
</div>
<div class="info">
<table width="100%" border="0">
<tbody>
<tr>
<td class="lines"><h1>157</h1></td>
<td class="dest"><h1>Out of Service</h1>
<h3>Streeterville/Taylor</h3>
<h3>Resumes 6:00 am</h3></td>
<td class="alert">
</td>
</tr>
</tbody>
</table>
</div>
</section>
<footer class="footer"></footer>
</section>
</div>
</div>
</body>
</html>
CSS
*, *:before, *:after {
box-sizing: border-box;
}
body {
background-color: #6E6C6C;
font-family: 'Roboto';
font-size: 16px;
color: #ffffff;
margin-top: 75px;
}
#table-wrapper {
position: relative;
}
#table-scroll {
height: 647px;
overflow: auto;
}
h1 {
font-size: 18px;
font-weight:600;
line-height: 1.3em;
color:#02356A;
}
h3 {
font-size: 14px;
font-weight: 400;
line-height: 1.3em;
color:#02356A;
}
.container {
margin: 0 auto;
width: 360px;
height: 667px;
}
nav {
margin: 0 auto;
position: fixed;
width: 360px;
height: 111px;
background-color: #164F9C;
}
.bus-list {
padding-top: 158px;
width: 100%;
padding-bottom: 50px;
}
.info {
text-align: left;
padding: 16px;
width: 100%;
background-color: #e5edf2;
border-bottom: thin #000000 solid;
}
.info:hover {
background-color: #81aef1;
}
.content {
width: 90%;
display:inline-block;
}
.icon {
width: 4px;
padding-left: 24px;
}
.title {
font-size: 20px;
color: #ffffff;
width: 180px;
padding-left: 32px;
vertical-align: middle;
line-height: 1.3em;
}
.ham-menu {
width: 24px;
}
.search-icon {
padding-left: 24px;
width: 24px;
}
.app-bar {
padding: 16px;
}
.route-bar {
background-color:#02356A;
height: 48px;
width: 360px;
text-align: left;
padding: 16px;
}
.lines {
text-align: left;
width: 100px;
}
.dest {
width: 37%;
}
.times {
width: 27%;
text-align: right;
}
.bottom-bar {
background-color: #000000;
margin-top: 425px;
}
.alert {
background-image: url(file:///C:/Users/Steve/bloc/frontend/images/alerts.png);
background-repeat: no-repeat;
background-size: 42px 38px;
background-position: right;
width: 27%;
}
.footer {
position: fixed;
background-color: #000000;
width: 360px;
bottom: 37px;
height: 48px;
background-image:url(file:///C:/Users/Steve/bloc/frontend/images/bottom-bar.png);
background-size: cover;
}
You have a bottom: 37px; in your CSS in the footer. Set this to 0px and you won't see the element under it anymore.

Print alignment and positioning header

I'm trying to print a page for which the fiddle is here http://jsfiddle.net/3J8TD/7/show/. The issue is, it is not aligned to center and it is not printing the header in every page. Look at this screenshot.
HTML:
<div style="" class="invoice-parent">
<div class="logo-container">
<div class="float-left"><img width="115" height="86" src="http://fc06.deviantart.net/fs70/i/2010/131/5/8/Dummy_company__Sample_logo_PSD_by_SolidSilver.jpg" ></div>
<div style="margin-top: 35px" class="float-left"><h1>Sample HEALTHCARE</h1></div>
</div>
<br clear="all" style="margin: 60px;">
<div class="left-address">
<u>C&F</u>: 21A/3, XXXXXX Street,<br>
<div style="margin-left:30px">
Collectorate,<br>
Abccde-324245,<br>
Qds dfs.<br>
Contact no. +91- 999999999999.<br>
Email: info#sampledomain.ext
</div>
</div>
<div class="right-address">
<u style="padding-right: 25px;">Corporate office:</u>
<div class="float-right">
78,8th Cross st,<br>
OMR,Koppasa,<br>
Chansoi -224 097.
</div>
</div>
<br clear="all">
<div id="bill_type">INVOICE</div>
<hr>
<div id="tin_cst_dll">
<span id="id-center">CST: 1085914</span>
</div>
<span style="margin-top: -16px;" class="float-left" id="id-left">TIN: 33893767761</span>
<span style="margin-top: -16px;" class="float-right" id="id-right">DL: TRT 2605/20B/2436/21B</span>
<hr>
<table width="100%" border="1" cellspacing="0" cellpadding="0" class="invoice-related">
<tbody><tr>
<td valign="top">
To: <strong id="to_name">Peter Agency</strong>,<br>
<div id="to_addresses">No.4, Fernanderz lane,<br>
Pandy street,<br>
Hobai - 982198. 0782-4379540
</div>
<strong>
<div id="customer_tin" class="float-left">Tin : 33893767754</div>
<div id="customer_dl" style="text-align: right;" class="float-right">DL no. : TRT 2605/20B/5342/21B</div>
<strong>
</strong></strong></td>
<td valign="top">
<div class="float-left" id="invnum"></div> <div class="float-right">Date: 12-07-2014</div><br>
</td>
</tr>
</tbody></table>
<div id="replacement_period" style="visibility: hidden;">Product Replacement for the period 01-03-2014 to 31-03-2014</div>
<table width="100%" border="1" align="left" cellspacing="0" cellpadding="0" class="invoice-related">
<tbody><tr>
<th valign="top">
S.no.
</th>
<th valign="top">
Product name
</th>
<th valign="top">
Packing
</th>
<th valign="top">
Batch no.
</th>
<th valign="top">
MFG Date
</th>
<th valign="top">
EXP date
</th>
<th valign="top">
MRP
</th>
<th valign="top">
Qty
</th>
<th valign="top" id="pts_head">
PTS
</th>
<th valign="top" id="amount_head">
Amount
</th>
</tr>
<tr class="item-row">
<td valign="top">
<div style="" class="delete-wpr"><a class="delete" href="javascript:;" title="Remove row">X</a></div><div class="sl_no">1</div>
</td>
<td valign="top">
CLOPS-75
</td>
<td valign="top">
<div class="packing">12</div>
</td>
<td valign="top">
<div class="batch">CL75</div>
</td>
<td valign="top">
<div class="mfg_date">06/2006</div>
</td>
<td valign="top">
<div class="exp_date">06/2022</div>
</td>
<td valign="top">
<div class="cost">575</div>
</td>
<td valign="top">8</td>
<td valign="top">
<div class="pts">414.00</div>
</td>
<td valign="top">
<div class="price">3312.00</div>
</td>
</tr><tr class="item-row"> <td valign="top"> <div style="" class="delete-wpr"><a class="delete" href="javascript:;" title="Remove row">X</a></div><div class="sl_no">2</div></td> <td valign="top">CLOPS-A </td> <td valign="top"> <div class="packing">12</div> </td> <td valign="top"> <div class="batch">CLA</div> </td> <td valign="top"> <div class="mfg_date">06/2006</div> </td> <td valign="top"> <div class="exp_date">06/2022</div> </td> <td valign="top"> <div class="cost">575</div> </td> <td valign="top">2</td> <td valign="top"> <div class="pts">414.00</div> </td> <td valign="top"> <div class="price">828.00</div> </td> </tr>
<tr class="item-calc">
<td class="blank vishide" colspan="8">By Cheque or Cash or DD.</td>
<td class="total-line balance">Subtotal</td>
<td class="total-value blank-value"><div id="sub_total">4140.00</div></td>
</tr>
<tr class="item-calc">
<td style="visibility: visible;" class="blank vishide" colspan="8">
Amount in words: <span id="number_in_words">Four thousand three hundred and forty seven rupees only </span>
</td>
<td class="total-line balance">Vat (5%)</td>
<td class="total-value blank-value"><div id="vat">207.00</div></td>
</tr>
<tr class="item-calc">
<td class="blank blank-bottom" colspan="8"> </td>
<td class="total-line balance">Grand Total</td>
<td class="total-value blank-value"><div id="grand_total">4347.00</div></td>
</tr>
</tbody></table>
<br clear="all">
<br clear="all">
<div id="tandc">
<u><b>Terms & Conditions</b></u>
<ul>
<li>All disputes subject to Chanso Jurisdiction only.</li>
<li>Certified that the particulars given above are true and correct.</li>
<li>And the amount indicated represents the price actually charged. </li>
<li>Cheques are subject to realisation for Aura Healthcare.</li>
</ul>
</div>
<div id="aura-signature">
For Sample Healthcare,<br><br><br>
<b>Authorised</b> <b>signatory.</b>
</div>
</div>
CSS:
#media print {
body * {
visibility: hidden;
}
div.invoice-parent, div.invoice-parent * {
visibility: visible;
}
div.invoice-parent {
left: 0;
top: 0;
position: absolute;
}
}
body { font-family: "Trebuchet MS","Helvetica","Arial","Verdana","sans-serif"; }
div.invoice-parent { width: 80%; margin: 0 auto; }
div.logo-container { width: 63%; margin: 0 auto; }
div.left-address { float: left; font-size: 15px;}
div.right-address { float: right; font-size: 15px;}
div#to_addresses { margin-left:30px; }
div#replacement_period { font-weight:bold; margin: 10px 0 10px 0; text-align: center; }
div#bill_type { font-size: 15px; font-weight: bold; margin: 20px; text-align: center; }
div#tandc { float: left; font-size: 12px; margin-top: 10px; width: 500px; }
div#aura-signature { margin-top:30px; float:right; }
hr { color: #4B78BB; margin: 20px 0;}
h1 { font-size: 35px; }
.float-left { float: left; }
.float-right { float: right; }
div#tin_cst_dll { left: 50%;
text-align: center;
top: 50%; }
span#id-center { margin:0 auto }
table.invoice-related { border-collapse: collapse; font-size: 13px;}
table.invoice-related td, table.invoice-related th {
border: 1px solid #000000;
padding: 5px;
}
table.invoice-related tr.item-calc {
height: 32px;
border-left: 1px solid #fff;
}
table.invoice-related td.blank {
border: 0 none;
}
table.invoice-related td.blank-value {
border-left: 0 none;
}
table.invoice-related td.blank-bottom {
border-bottom: 1px solid #FFFFFF;
}
table.invoice-related td.total-line {
border-right: 0 none;
text-align: right;
}
textarea { border: 0; overflow: hidden; resize: none; }
input.qty { border: 0 none; width: 40px; }
textarea:hover, textarea:focus, #items td.total-value textarea:hover, #items td.total-value textarea:focus, .delete:hover { background-color:#EEFF88; }
input.qty:hover, input.qty:focus { border: 0 none; overflow: hidden; resize: none; background-color: #EEFF88;}
.delete-wpr { position: relative; }
.delete { display: block; color: #000; text-decoration: none; position: absolute; background: #EEEEEE; font-weight: bold; padding: 0px 3px; border: 1px solid; top: -6px; left: -22px; font-family: Verdana; font-size: 12px; }
I tried giving various styles for both the parent and child divs. And for priting the header on every page, i tried giving the header fixed. But the logo is overlapping the content from second page. Any kind of help on this is appreciated. Please help.
Note: Please check the print preview of http://jsfiddle.net/3J8TD/7/show/ and not the HTML.
Make some changes in your code,
Decrease the top margin of div to 25px and remove the margin of <h1>
<div style="margin-top: 25px" class="float-left">
<h1 style="margin: 0">Sample HEALTHCARE</h1>
</div>
Add overflow:hidden; to div.logo-container and make the width: 100%
div.logo-container {
width: 100%;
margin: 0 auto;
overflow: hidden;
}
Check this Demo
Actual View is Here http://jsfiddle.net/amoljawale/3J8TD/8/show/

Can't center a table in HTML5/CSS3

I'm trying to center the rows in a table element on a page, and they won't center--and I've discovered that for some reason the tbody (and so, the table) width are expanding to the entire width of the page, so margin: 0, auto; will not then center the table.
Instead, the contents of the <tr>s end up all pushed to the left, no matter what I do. The only way I've been able to get the table centered is do something like set the table to width: 10px (obviously smaller than it actually is), but then it also squishes all of its descendants and removes my control over their width, which is not desirable.
How can I get this table centered? Happy to provide more detail as is necessary if the code isn't enough.
PHP/HTML:
<table id="items" class="inventory-table center" border="0" cellpadding="0" cellspacing="0" width="100%">
<?php for($i=0; $i<3; $i++) { ?>
<tr id="inventory-row-<?php echo $i ?>" class="inventory-row">
<td class="inventory-image">
<img src="<my image>" />
</td>
<td class="inventory-name">
Classic frame
</td>
<td class="inventory-price">
$<span class="price">139</span>
</td>
<td class="purchase-number-td">
<span class="purchase-number"></span>
</td>
<td>
<div data-inventoryrownumber="<?php echo $i; ?>" class="arrow-up top-arrow purchase-arrow"></div>
<div data-inventoryrownumber="<?php echo $i; ?>" class="arrow-down bottom-arrow purchase-arrow"></div>
</td>
</tr>
<?php } ?>
</table>
SASS:
/* inventory table css */
$triangle-size: 30px;
.inventory-table {
border-spacing: 10px;
margin: 0 auto;
}
.inventory-row {
display: inline-block;
td {
text-align: center;
}
}
.inventory-image img {
width: 200px;
height: auto;
}
td.purchase-number-td {
min-width: 30px;
}
.arrow-up {
width: 0;
height: 0;
border-left: $triangle-size solid transparent;
border-right: $triangle-size solid transparent;
border-bottom: $triangle-size solid black;
}
.arrow-down {
width: 0;
height: 0;
border-left: $triangle-size solid transparent;
border-right: $triangle-size solid transparent;
border-top: $triangle-size solid black;
}
.top-arrow {
margin-bottom: 30px;
}
.bottom-arrow {
margin-top: 30px;
}
Screenshot from Chrome dev tools:
Well, what about adding a table_conteiner which you do can center?
I've added a div called table_container, and I've centred it using margin: 0 auto;. As the table is inside, is centred in your markup. I've also removed inline-block from the tr, as it made not possible to the td expand to fill all the row. Note that I modified the values of the PHP and SASS from the file to make it pure HTML and CSS, as it's easier to everybody to test a pure markup problem.
/* inventory table css */
.inventory-table {
border-spacing: 10px;
margin: 0 auto;
}
.inventory-row {
/*display: inline-block;*/
}
.inventory-row td {
text-align: center;
}
.inventory-image img {
width: 200px;
height: auto;
}
td.purchase-number-td {
min-width: 30px;
}
.arrow-up {
width: 0;
height: 0;
border-left: 30px solid transparent;
border-right: 30px solid transparent;
border-bottom: 30px solid black;
}
.arrow-down {
width: 0;
height: 0;
border-left: 30px solid transparent;
border-right: 30px solid transparent;
border-top: 30px solid black;
}
.top-arrow {
margin-bottom: 30px;
}
.bottom-arrow {
margin-top: 30px;
}
.table_container {
width: 500px;
}
.table_container {
margin: 0 auto;
border: 1px solid black;
width: 700px
}
</style>
<div class="table_container">
<table id="items" class="inventory-table center" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr id="inventory-row-1" class="inventory-row">
<td class="inventory-image">
<img src="<my image>" />
</td>
<td class="inventory-name">
Classic frame
</td>
<td class="inventory-price">
$<span class="price">139</span>
</td>
<td class="purchase-number-td">
<span class="purchase-number"></span>
</td>
<td>
<div data-inventoryrownumber="1" class="arrow-up top-arrow purchase-arrow"></div>
<div data-inventoryrownumber="1" class="arrow-down bottom-arrow purchase-arrow"></div>
</td>
</tr>
<tr id="inventory-row-1" class="inventory-row">
<td class="inventory-image">
<img src="<my image>" />
</td>
<td class="inventory-name">
Classic frame
</td>
<td class="inventory-price">
$<span class="price">139</span>
</td>
<td class="purchase-number-td">
<span class="purchase-number"></span>
</td>
<td>
<div data-inventoryrownumber="1" class="arrow-up top-arrow purchase-arrow"></div>
<div data-inventoryrownumber="1" class="arrow-down bottom-arrow purchase-arrow"></div>
</td>
</tr>
<tr id="inventory-row-1" class="inventory-row">
<td class="inventory-image">
<img src="<my image>" />
</td>
<td class="inventory-name">
Classic frame
</td>
<td class="inventory-price">
$<span class="price">139</span>
</td>
<td class="purchase-number-td">
<span class="purchase-number"></span>
</td>
<td>
<div data-inventoryrownumber="1" class="arrow-up top-arrow purchase-arrow"></div>
<div data-inventoryrownumber="1" class="arrow-down bottom-arrow purchase-arrow"></div>
</td>
</tr>
</table>
</div>
Adjust the table margin, Add:
margin: 0 auto;
fiddle
HTML
<table>
<th colspan='3'>header</th>
<tr>
<td>data</td>
<td>data</td>
<td>data</td>
</tr>
<tr>
<td>data</td>
<td>data</td>
<td>data</td>
</tr>
</table>
CSS
table {
border: 1px solid red;
width: 100%; /* for small screens */
max-width: 20em; /* define width while keeping it flexible */
margin-right: auto;
margin-left: auto;
}