How to achieve table layout without using tables? - html

In the name of progress (and learning) how can I rid tables from my code and achieve the same layout?
For example, here is my table:
<table cellspacing="0px">
<tr>
<td>
<img src="http://www.poltairhomes.com/images/footerlogo.png" />
</td>
<td id="footertext">
<p>Poltair Homes Plc<br />Registered Office: The Old Chapel, Greenbottom, Truro, Cornwall, TR4 8QP.<br />Registered in England & Wales: 3955425<br />www.poltairhomes.com<br />info#poltairhomes.com</p>
</td>
<td id="footertext">
<p>Terms and Conditions | Privacy Policy | Sitemap</p>
</td>
<td id="footertext">
<p>SIGN UP FOR OUR NEWSLETTER:</p>
<img src="http://www.poltairhomes.com/images/signup(temp).png" />
</td>
</tr>
</table>
And the relevant CSS:
.footertext {
margin: 0;
padding:0 5px 0 5px;
color: #AAA;
font-size: 10px;
font-family:Arial, Helvetica, sans-serif;
text-align:center;
border-left: 1px solid #CCC;
}
http://jsfiddle.net/userdude/tYjKw/

CSS:
.table {
display: table;
}
.table-row {
display: table-row;
}
.table-cell {
display: table-cell;
}
HTML:
<div class="table">
<div class="table-row">
<div class="table-cell">Table cell 1</div>
<div class="table-cell">Table cell 2</div>
</div>
</div>

<div class="table">
<div class="row">
<div class="cell twocol">
<span>Content1</span>
</div>
<div class="cell twocol">
<span>Content2</span>
</div>
</div>
<div class="row">
<div class="cell onecol">
<span>Content3</span>
</div>
</div>
</div>
And the CSS
.table {width: 100%; height: 100%;}
.row {width: 100%; min-height: 1px; height: auto; margin: 0;}
.cell {float: left; margin: 0; padding: 0;}
.onecol {width: 100%;}
.twocol {width: 50%;}
I suggest you look into some gridsystems, like 960grid (http://960.gs/) or 1140grid (http://cssgrid.net/), will help you a lot.

Create a style as:
.footerItem { float: left; }
<div class="footerItem">
<img src="http://www.poltairhomes.com/images/footerlogo.png" />
</div>
<div class="footerItem">
<p>Poltair Homes Plc<br />Registered Office: The Old Chapel, Greenbottom, Truro, Cornwall, TR4 8QP.<br />Registered in England & Wales: 3955425<br />www.poltairhomes.com<br />info#poltairhomes.com</p>
</div>
<div class="footerItem">
<p>Terms and Conditions | Privacy Policy | Sitemap</p>
</div>
<div class="footerItem">
<p>SIGN UP FOR OUR NEWSLETTER:</p><img src="http://www.poltairhomes.com/images/signup(temp).png" />
</div>
and then create your body using DIVs to separate the blocks and apply the class to each one:

Related

using a div inside a td tag

i want a code which displays as
Account No:
But in my code its displayed as
and my code is as below
<td colspan="3">Account No:<div class="boxed">
</div>
<div class="boxed">
</div>
<div class="boxed">
</div>
<div class="boxed">
</div>
<div class="boxed">
</div>
</td>
Enclose the Account No. text with a div and add
CSS "float:left"
To that div.
Working code:
<table>
<tr>
<td colspan="3" style="float: left;">
<div style="float: left">Account No:</div>
<div class="boxed"></div>
<div class="boxed"></div>
<div class="boxed"></div>
<div class="boxed"></div>
<div class="boxed"></div>
</td>
</tr>
</table>
<style>
.boxed {
border: 1px solid;
width: 50px;
height: 50px;
float: left;
}
</style>
You can use div to wrap them and float.
<td colspan="3">
<div style="float:left;padding:15px 5px 0 0;">Account No:</div>
<div style="float:right;">
<div class="boxed"></div>
<div class="boxed"></div>
<div class="boxed"></div>
<div class="boxed"></div>
<div class="boxed"></div>
</div>
</td>
Fiddle
You can try this html structure and see fiddle link as below:
<td colspan="3">
<div class="title">
Account No:
</div>
<div class="boxed">
1
</div>
<div class="boxed">
2
</div>
<div class="boxed">
3
</div>
<div class="boxed">
4
</div>
<div class="boxed">
5
</div>
CSS:
.title {
float: left;
width: 20%;
}
.boxed {
border: 1px solid;
float: left;
padding: 10px 0;
text-align: center;
width: 7%;
}
https://jsfiddle.net/wwta4e8h/
.box{
border: 1px solid;
width: 30px;
height: 30px;
float: left;
}
<div style="float: left;">
<div style="float: left;padding-top:10px;padding-right:10px">Account No:</div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</div>
You can replace float: left; with display: inline-block; And in case if you want the boxes to ne top aligned add vertical-align: top;
<style>
.boxed {
border: 1px solid black;
display: inline-block;
vertical-align: top;
width:30px;
height:30px;
}
</style>

Creating complex table using CSS

I want to create something like this using divs and it also should be without using display:table css rule etc. How do I create table header this??
May be try this as a starting point? You might need to tweak it a lot.
* {box-sizing: border-box;}
.row {overflow: hidden; clear: both;}
.cell {border: 1px solid #999; padding: 0px; float: left;}
.cell.full {float: none;}
.col-1 {width: 20%;}
.col-2 {width: 40%;}
.col-3 {width: 60%;}
.col-33 {width: 33.3%;}
.row-2 {height: 3em;}
<div class="row">
<div class="cell col-1 row-2">Subject</div>
<div class="cell col-3 row-2">
<div class="row">
<div class="cell full">First Term</div>
</div>
<div class="row">
<div class="cell col-33">October Test</div>
<div class="cell col-33">December Exam</div>
<div class="cell col-33">Term Average</div>
</div>
</div>
<div class="col-1 row-2 cell">Teacher's Evaluation</div>
</div>
Preview:
If you can use flexbox can i use flexbox
The benefit of using flexbox is that you can get the the same result as you using the table tag including vertical-align:middle.
In the snippet, keep attention to the text-alignment in the cells.
You can use flexboxgrid like this:
[class*="col"] {
text-align:center;
border:1px solid;
display: flex;
justify-content: center;
flex-direction: column;
}
<link href="http://cdn.jsdelivr.net/flexboxgrid/6.3.0/flexboxgrid.min.css" rel="stylesheet" />
<div class="row ">
<div class="col-xs-3">Subject</div>
<div class="col-xs-6">
<div class="row">
<div class="col-xs-12">First Term</div>
</div>
<div class="row">
<div class="col-xs-4">October Test</div>
<div class="col-xs-4">December Exam</div>
<div class="col-xs-4">Term Average</div>
</div>
</div>
<div class="col-xs-3">Teacher's Evaluation</div>
</div>
The result:
http://jsbin.com/zetaro/edit?html,css,output
Just use colspan and rowspan =)
tutorial how to do it
I made it:
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
<table>
<tr>
<th rowspan="2"><br>Subject<br></th>
<th colspan="3">First term</th>
<th rowspan="2">Teacher's Evaluation</th>
</tr>
<tr>
<td>October test</td>
<td>December exam</td>
<td>Term Average</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
https://jsfiddle.net/b3aqLny1/
Try this
.table {
width: 100%;
table-layout: fixed;
display: table;
text-align: center;
}
.table .row{
display: table-row;
}
.table .row .col {
display: table-cell;
vertical-align: middle;
height: 100px;
border: 2px solid #333;
width: 33%;
}
.table .col.col-big {
width: 50%;
}
span {
display: inline-block;
padding: 10px;
}
.inner-table.table .row .col {border-width: 1px;}
<div class="table">
<div class="row">
<div class="col">
<span>Subject</span>
</div>
<div class="col col-big">
<div class="table inner-table">
<div class="row">
<div class="col one-col" style="width: 100%">
<span>First Term</span>
</div>
</div>
<div class="row">
<div class="table inner-table">
<div class="row">
<div class="col"><span>Test 1</span></div>
<div class="col"><span>Test 2</span></div>
<div class="col"><span>Test 3</span></div>
</div>
</div>
</div>
</div>
</div>
<div class="col">
<span>Teacher's Evaluation</span>
</div>
</div>
</div>

HTML Table: Having a border on just the table header with border-collapse:separate on the table

This is how I need my table to look:
I need to add a solid border beneath the table heading row. However, I also need to have spacing between the cells of the table. I have to use the border-collapse property on the table in order to get spacing between the gray cells, and "border-collapse: separate" prevents me from adding a bottom border to the heading row.
How can I add a solid border beneath the table header while also maintaining the spacing between the table columns?
These are the styles I have; the border-collapse style negates the border-bottom. When I remove the border-collapse, the border-bottom works.
tr.heading{
border-bottom: 1px solid black;
}
table{
border-collapse: separate;
}
Here's a fiddle:
https://jsfiddle.net/8u9krzyg/
This answer utilizes border:collapse; plus margin and border on your <div class="wrap"> element that you have in your table cells to provide the pseudo cell borders.
EDITED: I posted another method using ::after on the th elements to span the spacing. It has better browser support.
th {
text-align:left;
}
body.checkout-cart-2 { }
.checkout-cart-2 #cart-table{
width:100%;
}
.cart-status li {
display: inline;
}
.checkout-cart-2 .return-link {
margin:1.5em 0;
}
.checkout-cart-2 .cart-left {
margin-bottom:1.5em;
padding:15px;
}
.checkout-cart-2 .cart-left, .checkout-cart-2 .cart-right{
background:white;
}
#cart-table {
border-collapse: collapse; /* changed from separate */
border:none;
}
#cart-table th {
font-family: "Verdana";
font-size: 12px;
padding: 4px 10px;
text-transform: uppercase;
}
.cart-row {
font-family: "Verdana";
height: 100%; /* needed for full height .wrap */
}
.cart-row td {
vertical-align: top;
background: white;
padding: 0;
height: 100%;
}
.cart-row .description{
padding:0;
}
.cart-row .item-thumb{
padding-left:0;
}
.cart-row .item-name a {
font-size: 16px;
color: #0070c0;
font-weight: bold;
}
.cart-row .item-num {
font-size: 12px;
}
.cart-row .update a{
color: #0070c0;
}
.cart-row div.remove a.btn{
color: #0070c0;
background:none;
font-size:22px !important;
padding: 0 5px 0 1px;
}
.heading { /* new style */
border-bottom: 1px solid black;
}
.gray .wrap { /* new style - moved background color from td to .wrap */
background: #f6f6f6 none repeat scroll 0 0;
}
.wrap { /*new style to create pseudo cell borders */
height: 100%;
padding: 0 10px;
display: inline-block;
width: 100%; /* fall back for browsers that do not support calc()*/
width: calc(100% - 24px); /* calculates 100% width - 20 px padding + 4px right margin*/
border-bottom: 4px solid #f2f2f2;
margin-right: 4px; /* creates white space "pseudo/implied" border between cells */
}
.wrap > *:first-child {
padding-top: 10px;
}
.wrap > *:last-child {
padding-bottom: 10px;
}
.cart-row td:last-child .wrap, .remove .wrap {
margin-right: 0; /* removes "pseudo/implied" border on last cell .wrap */
width: calc(100% - 20px); /* Calculates 100% width - 20 px padding */
}
.availability>span {
font-weight: normal;
}
/* Clearfix */
.checkout-cart-2 .cart-left:before,
.checkout-cart-2 .cart-left:after {
content: " ";
display: table;}
.checkout-cart-2 .cart-left:after {
clear: both;}
.checkout-cart-2 ul.cart-items {
margin:0;
list-style:none;
}
#media all and (min-width: 769px) {
.checkout-cart-2 .cart-left {
float:left;
width:75%;
}
}
.checkout-cart-2 .cart-right {
margin-bottom:1.5em;
}
.checkout-cart-2 .cart-left .btns {
margin:1.5em 0;
}
.checkout-cart-2 .cart-left .btns .btn {
width:100%;
margin-bottom:1em;
}
.checkout-cart-2 .cart-right .btns a.btn {
width:100%;
margin-bottom:1em;
}
#media all and (min-width: 769px) {
.checkout-cart-2 .cart-right {
float:right;
width:25%;
}
}
.checkout-cart-2 .item-details .item-name {
padding-right:2.5em;
}
#media all and (min-width: 769px) {
.checkout-cart-2 .item-list .item-details {
padding-right:1em !important;
}
.checkout-cart-2 .item-details .item-name {
padding-right:3.5em;
}
.checkout-cart-2 .item-opt .item-subtotal {
float:right;
clear: right;
}
}
.checkout-cart-2 .item-list .actions-panel .item-actions {
text-align:left; }
.checkout-cart-2 .item-list .item-code-notes {
padding:0;
float:left;
width:100%;
}
.checkout-cart-2 .item-list .item-actions-wrap {
padding-left:0;
padding-right:0;
padding-bottom:0;
float:left;
width:100%;
}
.checkout-cart-2 .quote-items-note {
background:#fff6c5;
border-color:#ffd800;
}
<div id="cartgrid">
<table id="cart-table">
<tbody><tr class="heading">
<th>Product Information</th>
<th>Quantity</th>
<th>Item Price</th>
<th>Subtotal</th>
<th></th>
</tr>
<tr class="cart-row gray" data-orderlineid="02e9151d-24b4-46ca-8e9f-a4d000adbd83">
<td class="product-info" width="45%">
<div class="wrap">
<div class="small-4 columns item-thumb"><img src="" alt="95T Achieve Treadmill"></div>
<div class="small-8 columns description">
<div class="item-name">
<a href="">
95T Achieve Treadmill
</a>
</div>
<div class="item-num">
<span class="item-num-sku">Product Code: 456009801</span>
</div>
<div class="availability">
<span class="instock">In Stock</span>
</div>
</div>
</div>
</td>
<td class="quantity">
<div class="wrap">
<div class="item-qty">
<input type="text" id="02e9151d-24b4-46ca-8e9f-a4d000adbd83_qty" data-qty-input="" value="3" class="numerictextbox qty txt">
</div>
<div class="update">
<a class="update-btn" id="02e9151d-24b4-46ca-8e9f-a4d000adbd83_update" onclick="">Update</a>
</div>
</div>
</td>
<td class="price">
<div class="wrap">
<div class="price">
<span class="price">$3,599.00</span>
</div>
</div>
</td>
<td class="subtotal">
<div class="wrap">
<div class="price">
<div class="item-subtotal">
$10,797.00 </div>
</div>
</div>
</td>
<td class="remove">
<div class="wrap">
<div class="remove">
<a class="btn btn-remove" onclick="">
<i class="fa fa-times"></i>
</a>
</div>
</div>
</td>
</tr>
<tr class="cart-row" data-orderlineid="01a6aefa-7bb7-4559-b4db-a4d000c95fc8">
<td class="product-info" width="45%">
<div class="wrap">
<div class="small-4 columns item-thumb"><img src="" alt="Biceps Curl"></div>
<div class="small-8 columns description">
<div class="item-name">
<a href="">
Biceps Curl
</a>
</div>
<div class="item-num">
<span class="item-num-sku">Product Code: 455009813</span>
</div>
<div class="availability">
<span class="instock">In Stock</span>
</div>
</div>
</div>
</td>
<td class="quantity">
<div class="wrap">
<div class="item-qty">
<input type="text" id="01a6aefa-7bb7-4559-b4db-a4d000c95fc8_qty" data-qty-input="" value="1" class="numerictextbox qty txt">
</div>
<div class="update">
<a class="update-btn" id="01a6aefa-7bb7-4559-b4db-a4d000c95fc8_update" onclick="">Update</a>
</div>
</div>
</td>
<td class="price">
<div class="wrap">
<div class="price">
<span class="price">$149.99</span>
</div>
</div>
</td>
<td class="subtotal">
<div class="wrap">
<div class="price">
<div class="item-subtotal">
$149.99 </div>
</div>
</div>
</td>
<td class="remove">
<div class="wrap">
<div class="remove">
<a class="btn btn-remove" onclick="">
<i class="fa fa-times"></i>
</a>
</div>
</div>
</td>
</tr>
<tr class="cart-row gray" data-orderlineid="2d0c2838-645a-4849-9600-a4d000c9627a">
<td class="product-info" width="45%">
<div class="wrap">
<div class="small-4 columns item-thumb"><img src="" alt="XI8 CYCLEPRO Exercise Bike"></div>
<div class="small-8 columns description">
<div class="item-name">
<a href="">
XI8 CYCLEPRO Exercise Bike
</a>
</div>
<div class="item-num">
<span class="item-num-sku">Product Code: LFR3995</span>
</div>
<div class="availability">
<span class="instock">In Stock</span>
</div>
</div>
</div>
</td>
<td class="quantity">
<div class="wrap">
<div class="item-qty">
<input type="text" id="2d0c2838-645a-4849-9600-a4d000c9627a_qty" data-qty-input="" value="1" class="numerictextbox qty txt">
</div>
<div class="update">
<a class="update-btn" id="2d0c2838-645a-4849-9600-a4d000c9627a_update" onclick="">Update</a>
</div>
</div>
</td>
<td class="price">
<div class="wrap">
<div class="price">
<span class="price-sale">$1,999.99</span>
<span class="price-old">$2,199.00</span>
</div>
</div>
</td>
<td class="subtotal">
<div class="wrap">
<div class="price">
<div class="item-subtotal">
$1,999.99 </div>
</div>
</div>
</td>
<td class="remove">
<div class="wrap">
<div class="remove">
<a class="btn btn-remove" onclick="">
<i class="fa fa-times"></i>
</a>
</div>
</div>
</td>
</tr>
</tbody></table>
</div>
Another Method
Here is another method that uses th::after to create the border underneath the table headers. This method has better cross browser support.
th {
text-align:left;
}
body.checkout-cart-2 { }
.checkout-cart-2 #cart-table{
width:100%;
}
.cart-status li {
display: inline;
}
.checkout-cart-2 .return-link {
margin:1.5em 0;
}
.checkout-cart-2 .cart-left {
margin-bottom:1.5em;
padding:15px;
}
.checkout-cart-2 .cart-left, .checkout-cart-2 .cart-right{
background:white;
}
#cart-table {
border-collapse: separate:
border:none;
}
#cart-table th {
font-family: "Verdana";
font-size: 12px;
padding: 4px 10px;
text-transform: uppercase;
position: relative;
border-bottom: solid 2px black; /* base/fallback border for older browsers */
}
.cart-row {
font-family: "Verdana";
height: 100%; /* needed for full height .wrap */
}
.cart-row td {
vertical-align: top;
background: white;
padding: 10px;
height: 100%;
}
.cart-row .description{
padding:0;
}
.cart-row .item-thumb{
padding-left:0;
}
.cart-row .item-name a {
font-size: 16px;
color: #0070c0;
font-weight: bold;
}
.cart-row .item-num {
font-size: 12px;
}
.cart-row .update a{
color: #0070c0;
}
.cart-row div.remove a.btn{
color: #0070c0;
background:none;
font-size:22px !important;
padding: 0 5px 0 1px;
}
.heading {
position: relative;
}
#cart-table th::after { /* creates a pseudo border to span gap in th spacing */
background: black none repeat scroll 0 0;
bottom: -2px;
content: "";
display: block;
height: 2px; /* matches #cart-table th border-bottom value */
left: 0px;
position: absolute;
right: -2px; /* Matches table border-spacing value */
}
#cart-table th:last-child::after {
right: 0px; /* Reset pseudo border so it does not extend outside of table */
}
.gray td { /* new style - moved background color from td to .wrap */
background: #f6f6f6 none repeat scroll 0 0;
}
.availability>span {
font-weight: normal;
}
/* Clearfix */
.checkout-cart-2 .cart-left:before,
.checkout-cart-2 .cart-left:after {
content: " ";
display: table;}
.checkout-cart-2 .cart-left:after {
clear: both;}
.checkout-cart-2 ul.cart-items {
margin:0;
list-style:none;
}
#media all and (min-width: 769px) {
.checkout-cart-2 .cart-left {
float:left;
width:75%;
}
}
.checkout-cart-2 .cart-right {
margin-bottom:1.5em;
}
.checkout-cart-2 .cart-left .btns {
margin:1.5em 0;
}
.checkout-cart-2 .cart-left .btns .btn {
width:100%;
margin-bottom:1em;
}
.checkout-cart-2 .cart-right .btns a.btn {
width:100%;
margin-bottom:1em;
}
#media all and (min-width: 769px) {
.checkout-cart-2 .cart-right {
float:right;
width:25%;
}
}
.checkout-cart-2 .item-details .item-name {
padding-right:2.5em;
}
#media all and (min-width: 769px) {
.checkout-cart-2 .item-list .item-details {
padding-right:1em !important;
}
.checkout-cart-2 .item-details .item-name {
padding-right:3.5em;
}
.checkout-cart-2 .item-opt .item-subtotal {
float:right;
clear: right;
}
}
.checkout-cart-2 .item-list .actions-panel .item-actions {
text-align:left; }
.checkout-cart-2 .item-list .item-code-notes {
padding:0;
float:left;
width:100%;
}
.checkout-cart-2 .item-list .item-actions-wrap {
padding-left:0;
padding-right:0;
padding-bottom:0;
float:left;
width:100%;
}
.checkout-cart-2 .quote-items-note {
background:#fff6c5;
border-color:#ffd800;
}
<div id="cartgrid">
<table id="cart-table">
<tbody><tr class="heading">
<th>Product Information</th>
<th>Quantity</th>
<th>Item Price</th>
<th>Subtotal</th>
<th></th>
</tr>
<tr class="cart-row gray" data-orderlineid="02e9151d-24b4-46ca-8e9f-a4d000adbd83">
<td class="product-info" width="45%">
<div class="wrap">
<div class="small-4 columns item-thumb"><img src="" alt="95T Achieve Treadmill"></div>
<div class="small-8 columns description">
<div class="item-name">
<a href="">
95T Achieve Treadmill
</a>
</div>
<div class="item-num">
<span class="item-num-sku">Product Code: 456009801</span>
</div>
<div class="availability">
<span class="instock">In Stock</span>
</div>
</div>
</div>
</td>
<td class="quantity">
<div class="wrap">
<div class="item-qty">
<input type="text" id="02e9151d-24b4-46ca-8e9f-a4d000adbd83_qty" data-qty-input="" value="3" class="numerictextbox qty txt">
</div>
<div class="update">
<a class="update-btn" id="02e9151d-24b4-46ca-8e9f-a4d000adbd83_update" onclick="">Update</a>
</div>
</div>
</td>
<td class="price">
<div class="wrap">
<div class="price">
<span class="price">$3,599.00</span>
</div>
</div>
</td>
<td class="subtotal">
<div class="wrap">
<div class="price">
<div class="item-subtotal">
$10,797.00 </div>
</div>
</div>
</td>
<td class="remove">
<div class="wrap">
<div class="remove">
<a class="btn btn-remove" onclick="">
<i class="fa fa-times"></i>
</a>
</div>
</div>
</td>
</tr>
<tr class="cart-row" data-orderlineid="01a6aefa-7bb7-4559-b4db-a4d000c95fc8">
<td class="product-info" width="45%">
<div class="wrap">
<div class="small-4 columns item-thumb"><img src="" alt="Biceps Curl"></div>
<div class="small-8 columns description">
<div class="item-name">
<a href="">
Biceps Curl
</a>
</div>
<div class="item-num">
<span class="item-num-sku">Product Code: 455009813</span>
</div>
<div class="availability">
<span class="instock">In Stock</span>
</div>
</div>
</div>
</td>
<td class="quantity">
<div class="wrap">
<div class="item-qty">
<input type="text" id="01a6aefa-7bb7-4559-b4db-a4d000c95fc8_qty" data-qty-input="" value="1" class="numerictextbox qty txt">
</div>
<div class="update">
<a class="update-btn" id="01a6aefa-7bb7-4559-b4db-a4d000c95fc8_update" onclick="">Update</a>
</div>
</div>
</td>
<td class="price">
<div class="wrap">
<div class="price">
<span class="price">$149.99</span>
</div>
</div>
</td>
<td class="subtotal">
<div class="wrap">
<div class="price">
<div class="item-subtotal">
$149.99 </div>
</div>
</div>
</td>
<td class="remove">
<div class="wrap">
<div class="remove">
<a class="btn btn-remove" onclick="">
<i class="fa fa-times"></i>
</a>
</div>
</div>
</td>
</tr>
<tr class="cart-row gray" data-orderlineid="2d0c2838-645a-4849-9600-a4d000c9627a">
<td class="product-info" width="45%">
<div class="wrap">
<div class="small-4 columns item-thumb"><img src="" alt="XI8 CYCLEPRO Exercise Bike"></div>
<div class="small-8 columns description">
<div class="item-name">
<a href="">
XI8 CYCLEPRO Exercise Bike
</a>
</div>
<div class="item-num">
<span class="item-num-sku">Product Code: LFR3995</span>
</div>
<div class="availability">
<span class="instock">In Stock</span>
</div>
</div>
</div>
</td>
<td class="quantity">
<div class="wrap">
<div class="item-qty">
<input type="text" id="2d0c2838-645a-4849-9600-a4d000c9627a_qty" data-qty-input="" value="1" class="numerictextbox qty txt">
</div>
<div class="update">
<a class="update-btn" id="2d0c2838-645a-4849-9600-a4d000c9627a_update" onclick="">Update</a>
</div>
</div>
</td>
<td class="price">
<div class="wrap">
<div class="price">
<span class="price-sale">$1,999.99</span>
<span class="price-old">$2,199.00</span>
</div>
</div>
</td>
<td class="subtotal">
<div class="wrap">
<div class="price">
<div class="item-subtotal">
$1,999.99 </div>
</div>
</div>
</td>
<td class="remove">
<div class="wrap">
<div class="remove">
<a class="btn btn-remove" onclick="">
<i class="fa fa-times"></i>
</a>
</div>
</div>
</td>
</tr>
</tbody></table>
</div>
For some reason I'm not sure you'll like my answer, however add the following after the heading row:
<tr><td style="border-top:1px solid black;" colspan="4"></td></tr>
where 4 is the number of columns. The border line will nicely ignore cell spacing, because it's one cell.

How do you make HTML elements appear on a vertical line using CSS?

Image of the problem:
How do I go from the one on the left, to the one on the right, using CSS?
You can use a table:
<table>
<tr>
<td>You own</td>
<td>20</td>
</tr>
<tr>
<td>Price</td>
<td>20</td>
</tr>
<tr>
<td>BPS</td>
<td>0.50</td>
</tr>
</table>
or floating divs:
<div style="display:inline-block;">
<div style="float:left; width:150px;">You own</div>
<div style="float:left;">20</div>
</div>
<div style="display:inline-block;">
<div style="float:left; width:150px;">Price</div>
<div style="float:left;">20</div>
</div>
<div style="display:inline-block;">
<div style="float:left; width:150px;">BPS</div>
<div style="float:left;">0.50</div>
</div>
<div>
<div id="left"> <!-- float left -->
<p>You Own></p>
<p>Price</p>
<p>BPS</p>
</div>
<div id="right">
<p>20</p>
<p>20</p>
<p>0.50</p>
</div>
</div>
Two divs
<div class="box">
Your own:<br />
Price:<br />
PBS
</div>
<div class="box">
20<br />
20<br />
50
</div>
CSS
.box {
float:left;
padding-right:40px;
}
While I am in agreement that this can be a table, you can easily do this with floats.
.container {
padding: 0.5em;
width: 200px;
background: #333;
color: #fff;
}
.button {
background: #efefef;
padding: 5px;
color: #000;
margin-bottom: 0.5em;
}
.item-header {
font-weight:bold;
float:left;
width: 45%;
clear:both;
}
<div class="container">
<div class="button">Buy Foreign Worker</div>
<div class="items">
<div class="item-header">You Own:</div>
<div class="item-value">20</div>
<div class="item-header">Price:</div>
<div class="item-value">20</div>
<div class="item-header">BPS:</div>
<div class="item-value">0.5</div>
</div>
</div>
All you are doing is making the header values float to the left, and the clear ensures that it starts on a new row.

Colspan alternative in <div> based structure

I want to use div elements to create a table-like layout.
What I want
.tableStyle td {
background: red;
color: #fff
}
.contentBox {
min-height: 200px;
}
<table class="tableStyle" width="100%" cellspacing="10">
<tr>
<td width="25%">
<div class="contentBox">One</div>
</td>
<td width="25%">Two</td>
<td width="50%" colspan="2">Three</td>
</tr>
<tr>
<td colspan="2">
<div class="contentBox">Four</div>
</td>
<td colspan="2">Five</td>
</tr>
</table>
What I have
.table {
display: table;
width: 100%;
border-collapse: separate;
border-spacing: 10px;
color: #fff
}
.table .row {
display: table-row;
}
.table .table-cell {
display: table-cell;
background: red;
width: 50%;
}
.contentBox {
min-height: 200px;
}
.table .smlCell {
width: 25%;
}
.table .table {
border-spacing: 0;
}
<div class="table">
<div class="row">
<div class="table-cell">
<div class="table">
<div class="row">
<div class="table-cell smlCell">
<div class="contentBox">One</div>
</div>
<div class="table-cell smlCell">
Two
</div>
</div>
</div>
</div>
<div class="table-cell">Three</div>
</div>
<div class="row">
<div class="table-cell">
<div class="contentBox">Four</div>
</div>
<div class="table-cell">Five</div>
</div>
</div>
I want to have equal spacing between the cells marked "One" and "Two".
I also want all cells in a row to be of same height.
After searching on net, I know that there are some limitations or issues
for display: table such as a lack of colspan/rowspan equivalents which may help what I'm trying to accomplish.
Is there anyway (apart form <table>) to create this?
Sure there is!
Demo Fiddle
HTML
<div class='table'>
<div class='row'>
<div class='table'>
<div class='cell'>One</div>
<div class='cell'>Two</div>
</div>
<div class='cell'>Three</div>
</div>
<div class='row'>
<div class='cell'>Four</div>
<div class='cell'>Five</div>
</div>
</div>
CSS
html, body{
width:100%;
height:100%;
margin:0;
padding:0;
}
.table {
display:table;
width:100%;
height:100%;
}
.cell {
display:table-cell;
width:50%;
}
.row {
display:table-row;
}
.cell {
background:red;
color:white;
border:5px solid white;
}
Try this. I have used inline instead of CSS class. You had placed one div in wrong location.
<div class="table">
<div class="row">
<div class="table-cell">
<div class="table">
<div class="row">
<div class="table-cell smlCell">
<div style="width:50% float: left" class="contentBox">One
</div>
<div style="width:50% float: right" class="contentBox">
Two
</div>
</div>
</div>
</div>
</div>
<div class="table-cell">Three</div>
</div>
<div class="row">
<div class="table-cell">
<div class="contentBox">Four</div>
</div>
<div class="table-cell">Five</div>
</div>
</div>
with support for older (ms-explorer?). But if your content is table by it's nature, use table and not those tricks :-)
<!DOCTYPE HTML>
<html>
<head>
<title>Bla!</title>
<style type='text/css'>
/* reset sizing model ... */
* { box-sizing: border-box; -webkit-box-sizing: border-box;-moz-box-sizing: border-box; }
/* basic div definitions */
div { display:inline-block; min-height:50px; background-color:red; border:solid 3px white; }
/* 1/2 line div */
div.half { width:50%; }
/* 1/4 line div */
div.quater { width:25%; }
</style>
</head>
<body class='body' id='body' >
<div class='quater'> One </div><div class='quater'> Two </div><div class='half'> Three </div><div class='half'> Four </div><div class='half'> Five </div>
</body>
</html>