CSS fixed column on table disappears on iPhone web browser - html

I have a responsive CSS scrollable table with the first column fixed.
But on the iPhone web browser (Safari), the first column disappears. If you turn the iPhone on sideways/landscape, the fixed first column becomes visible. This was tested on iPhone X and 5.
On Android phones, this does not seem to be a problem.
Any idea what could be causing this problem on iPhone?
div.page {
width: 90%;
margin: 0 auto;
background: white;
padding: 0px 10px 0px 10px;
box-shadow: 0px -1px 11px 0px rgba(50, 50, 50, 0.95);
}
div.header {
width: 100%;
margin: 0 auto 5px;
padding-bottom: 10px;
background: #EBEBEB url('images/p5.png') repeat scroll;
}
.clear {
clear: both;
}
div.main {
clear: both;
}
div.calc {
width: 810px;
float: left;
}
table.calc {
border-collapse: collapse;
font-family: Calibri;
width: 808px;
border-bottom: medium silver solid;
}
#comparemob {
display: none;
}
table.calc th[scope=col] {
font-family: Arial, Helvetica, sans-serif;
font-weight: normal;
}
table.calc th[scope=row] {
padding-left: 5px;
text-align: left;
font-size: 1.6em;
font-weight: bold;
width: 332px;
}
table.calc th#gross {
background-color: white;
background-image: linear-gradient(to top, rgba(128, 128, 128, 1), rgba(128, 128, 128, 0.5));
}
table.calc th#holiday {
background-color: white;
background-image: linear-gradient(to top, rgba(255, 255, 0, 1), rgba(255, 255, 0, 0.5));
}
table.calc th#empni {
background-color: white;
background-image: linear-gradient(to top, rgba(187, 86, 93, 1), rgba(187, 86, 93, 0.6));
}
table.calc th#umbfee {
background-color: white;
background-image: linear-gradient(to top, rgba(165, 129, 61, 1), rgba(165, 129, 61, 0.7));
}
table.calc th#expense {
background-color: white;
background-image: linear-gradient(to top, rgba(255, 153, 0, 1), rgba(255, 153, 0, 0.7));
}
table.calc th#salary {
background-color: white;
background-image: linear-gradient(to top, rgba(153, 153, 153, 1), rgba(153, 153, 153, 0.7));
}
table.calc th#taxable {
font-style: italic;
background-color: white;
background-image: linear-gradient(to top, rgba(166, 166, 166, 1), rgba(166, 166, 166, 0.7));
}
table.calc th#persallow {
background-color: white;
background-image: linear-gradient(to top, rgba(74, 174, 254, 1), rgba(74, 174, 254, 0.7));
}
table.calc th#married {
background-color: white;
background-image: linear-gradient(to top, rgba(128, 198, 254, 1), rgba(128, 198, 254, 0.7));
}
table.calc th#taxpaid {
background-color: white;
background-image: linear-gradient(to top, rgba(255, 0, 0, 1), rgba(255, 0, 0, 0.7));
}
table.calc th#nicontri {
background-color: white;
background-image: linear-gradient(to top, rgba(255, 51, 51, 1), rgba(255, 51, 51, 0.8));
}
table.calc th#tdeduct {
background-color: white;
background-image: linear-gradient(to top, rgba(255, 77, 77, 1), rgba(255, 77, 77, 0.8));
}
table.calc th#takehome {
background-color: white;
background-image: linear-gradient(to top, rgba(0, 204, 0, 1), rgba(0, 204, 0, 0.7));
}
table.calc td {
font-size: 1.6em;
}
table.calc td:nth-child(odd) {
background-image: url('images/Untitled-1.png');
}
table.calc tfoot th {
padding-left: 5px;
text-align: left;
background-color: #838383;
color: white;
}
table.calc tfoot td {
padding: 0px 0px 0px 10px;
font-size: medium;
background-color: #CDCDCD;
color: #666666;
}
.row1 {
background-color: #d8d8d8;
}
.row2 {
background-color: #ffffa8;
}
.row3 {
background-color: #f7b9bd;
}
.row4 {
background-color: #dac399;
}
.row5 {
background-color: #fbca81;
}
.row6 {
background-color: #d8d8d8;
}
.row7 {
background-color: #e6e6e6;
}
.row8 {
background-color: #a8d8ff;
}
.row9 {
background-color: #c7e6ff;
}
.row10 {
background-color: #ffa3a3;
}
.row11 {
background-color: #fdbfbe;
}
.row12 {
background-color: #ffcaca;
}
.row13 {
background-color: #A9F5A9;
}
/*table*/
table.rate {
border-collapse: separate;
border-spacing: 1px;
margin-bottom: 20px;
}
table.rate th,
tr,
td {
padding: 5px 10px;
}
table.rate th {
background-color: #60AFDB;
border-bottom: 5px #0066CC solid;
}
table.rate td {
background-color: #F6FDFF;
border-bottom: 1px #60AFDB solid;
}
table.rate tbody {
display: table-row-group;
border-bottom: medium #60AFDB solid;
}
#media only screen and (max-width: 740px) {
body,
div.data,
.scroll/*, .main*/
{
width: 100%;
}
div.page {
width: unset;
margin: unset;
padding: 0px 0px 0px 0px;
}
div.main {
margin: 0 auto;
padding: 0 10px 0 10px;
display: flex;
flex-direction: column;
/*padding: 0px 10px 0px 10px;*/
}
div.calc {
width: 100%;
}
table.calc th[scope=col] {
font-family: Calibri;
font-weight: normal;
}
.tabs {
width: max-content;
padding: 2px 5px 1px 2px;
}
.line {
width: max-content;
}
.mscroll {
/*width: 100%;*/
overflow-x: scroll;
margin-left: 105px;
-webkit-overflow-scrolling: touch;
}
.colfix,
#compare,
#blank {
position: absolute;
left: 10px;
}
.colfix1 {
position: absolute;
height: 20px;
width: 85px;
left: 20px;
border-bottom: 2px black solid;
border-top: 2px black solid;
margin: 0 0 0 0;
padding: 0 0 0 0;
}
table.calc {
float: left;
width: 300px;
}
table.calc th[scope=row] {
font-size: 1.0em;
width: 100px;
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="en-gb" http-equiv="Content-Language" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<title>table</title>
<link rel="stylesheet" href="styles10.css" type="text/css" />
<style type="text/css">
a {
color: #0066CC;
}
* {
margin: 0;
padding: 0;
}
</style>
<script type="text/javascript" src="script1.js">
<!--
//-->
</script>
</head>
<body>
<div class="page">
<div class="main">
<div class="calc">
<div style="clear:left">
<p>Test</p>
</div>
<div class="mscroll">
<table class="calc">
<tr style="border-bottom:2px black solid; border-top:2px black solid;">
<th scope="col" style="border-bottom:2px black solid; border-top:2px black solid; height:22px; padding:0 0 -2px 5px; margin: -2px 0 -1px 3px;" id="blank">
</th>
<th class="slmrow" scope="col">1</th>
<th class="slmrow" scope="col">2</th>
<th class="slmrow" scope="col">3</th>
<th class="slmrow" scope="col">4</th>
</tr>
<tr id="gr" style="display:none;" class="row1">
<th scope="row" id="gross" class="colfix" style="height: 43px">Name</th>
<td style="height: 43px"></td>
<td style="height: 43px"></td>
<td style="height: 43px"></td>
<td style="height: 43px"></td>
</tr>
<tr id="hf" style="display:none;" class="row2">
<th scope="row" id="holiday" class="colfix">Name</th>
<td> </td>
<td></td>
<td></td>
<td></td>
</tr>
<tr id="emni" style="display:none;" class="row3">
<th scope="row" id="empni" class="colfix">Name</th>
<td> </td>
<td></td>
<td></td>
<td></td>
</tr>
<tr id="umbf" style="display:none;" class="row4">
<th scope="row" id="umbfee" class="colfix">Name</th>
<td> </td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="row6">
<th class="colfix" scope="row" id="salary" class="colfix">Name</th>
<td> </td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="row8">
<th scope="row" id="persallow" class="colfix">Name</th>
<td> </td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="row10">
<th scope="row" id="taxpaid" class="colfix">Name</th>
<td> </td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="row11">
<th scope="row" id="nicontri" class="colfix" style="height: 43px">
Name</th>
<td style="height: 43px"></td>
<td style="height: 43px"></td>
<td style="height: 43px"></td>
<td style="height: 43px"></td>
</tr>
<tr id="hidetd" class="row12">
<th scope="row" id="tdeduct" class="colfix">Name</th>
<td><em> </em></td>
<td><em></em></td>
<td><em></em></td>
<td><em></em></td>
</tr>
<tr class="row13">
<th scope="row" id="take2" class="colfix">Name</th>
<td><strong> </strong></td>
<td><strong></strong></td>
<td><strong></strong></td>
<td><strong></strong></td>
</tr>
<tfoot>
<tr id="hidecompare">
<th class="slmrow" id="compare" style="height:19px;"><span id="comparedesktop">
Name</span></th>
<td><strong> </strong></td>
<td><strong></strong></td>
<td><strong></strong></td>
<td><strong></strong></td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</body>
</html>
Below you can see the first column missing on iPhone:

I started removing your code piece by piece to see when the problem goes away. Removing <div class="mscroll"> made the problem go away. So I took closer look at the css and from there the problem seems to be in:
-webkit-overflow-scrolling: touch;
Remove that from .mscroll and it will work on iphone.
I did my best on trying to understand why this happens. But I don't seem to find any reason for it. I would assume, that your code is a bit messy and probably there is a conflict somewhere.

Related

backdrop-filter not working with <table> tag

I want to give Glassmorphism effect to each row in table tag and backdrop-filter is not working with tr tag. How to give blur effect to row or any alternative css property for achieve it ?
<!DOCTYPE html>
<Style>
body {
background: rgb(179, 179, 201);
background: linear-gradient(90deg, rgba(179, 179, 201, 1) 0%, rgba(216, 216, 224, 1) 99%);
}
table {
margin-top: 5%;
margin-left: 20%;
width: 50%;
border-collapse: separate;
border-spacing: 0 40px;
}
tr {
height: 100px;
padding: 50px;
background: rgba( 4, 9, 210, 0.30);
box-shadow: 0 8px 32px 0 rgba( 31, 38, 135, 0.37);
backdrop-filter: blur( 2.5px);
-webkit-backdrop-filter: blur( 2.5px);
border: 1px solid rgba( 255, 255, 255, 0.18);
}
</style>
<body>
<table cellspacing=0>
<tbody>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<td>80</td>
</tr>
</tbody>
</table>
</body>
</html>
Applying the backdrop-filter to the td instead produces the intended effect. I've also dropped in a more defined image to show results.
body{
background: rgb(179,179,201);
background: linear-gradient(90deg, rgba(179,179,201,1) 0%, rgba(216,216,224,1) 99%);
background: url(http://www.fillmurray.com/1000/1000);
}
table{
margin-top: 5%;
margin-left: 20%;
width:50%;
border-collapse: separate;
border-spacing: 0 40px;
}
tr{
height: 100px;
padding:50px;
background: rgba( 4, 9, 210, 0.30 );
box-shadow: 0 8px 32px 0 rgba( 31, 38, 135, 0.37 );
border: 1px solid rgba( 255, 255, 255, 0.18 );
}
td {
backdrop-filter: blur( 10px );
-webkit-backdrop-filter: blur( 10px );
}
Be sure to close your style element. Beware, backdrop-filter doesn't work on Firefox by default.
*Edit: Limited Support (tested on Safari, no Chrome/default Firefox support)
Make sure the opening <style> tag starts with a lower case. Also for the blur effects to be prominent you might need a background image or some elements behind the tr elements. Below I put a div (#Test_Rectangle) to show the effects of the backdrop-filter(). Keep in mind to beware of the lack of support for backdrop-filters in Firefox's default configuration. Press the blue Run code snippet button below to see the results:
body {
background: rgb(179, 179, 201);
background: linear-gradient(90deg, rgba(179, 179, 201, 1) 0%, rgba(216, 216, 224, 1) 99%);
}
#Test_Rectangle{
position: absolute;
height: 50vw;
width: 50vw;
top: 0px;
left: 0px;
background: cyan;
}
table {
margin-top: 5%;
margin-left: 20%;
width: 50%;
border-collapse: separate;
border-spacing: 0 40px;
}
tr {
height: 100px;
padding: 50px;
background: rgba(4, 9, 210, 0.30);
box-shadow: 0 8px 32px 0 rgba( 31, 38, 135, 0.37);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.18);
}
<html>
<body>
<div id="Test_Rectangle"></div>
<table cellspacing=0>
<tbody>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<td>80</td>
</tr>
</tbody>
</table>
</body>
</html>

Why my border color doesn't change even If I already tried it using specific value

I'm sorry if the title make you confused, I wonder my table border suddenly lost it color
#my-table table {
font-family: "Nunito", sans-serif;
font-size: 18px;
color: #1d3962;
margin: 0% auto;
border-collapse: collapse;
border-spacing: 0;
width: 100%;
max-width: 1200px;
border: none;
border-top: none;
}
#my-table tr{
border-top: solid 2px rgba(58, 115, 197, 0.1);
}
#my-table tr:nth-child(1){
border-top: none;
}
#my-table tr:nth-last-child(1){
border-bottom: none;
}
#my-table td{
width: 25%;
}
#my-table .first{
border-top: solid 2px rgba(58, 115, 197, 0.4);
}
#my-table tr td:nth-child(1){
padding: 0px 0px;
}
#my-table tr th:nth-child(2){
font-weight: bold;
background-color: rgba(46, 207, 47, 0.1);
border-top-right-radius: 20px;
border-top-left-radius: 20px;
padding: 32px 38px;
}
#my-table tr td:nth-child(2){
background-color: rgba(46, 207, 47, 0.1);
padding: 32px 38px;
}
#my-table tr th:nth-child(3){
font-weight: bold;
background-color: rgba(219, 206, 44, 0.1);
border-top-right-radius: 20px;
border-top-left-radius: 20px;
padding: 32px 38px;
}
#my-table tr td:nth-child(3){
background-color: rgba(219, 206, 44, 0.1);
padding: 32px 38px;
}
#my-table tr th:nth-child(4){
font-weight: bold;
background-color: rgba(229, 76, 110, 0.1);
border-top-right-radius: 20px;
border-top-left-radius: 20px;
padding: 32px 38px;
}
#my-table tr td:nth-child(4){
color: #E54C6E;
background-color: rgba(229, 76, 110, 0.1);
padding: 32px 38px;
margin: 0% 15px;
}
#my-table .test{
padding-right: 20px;
}
#my-table tr td{
padding: 32px 38px;
}
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body id="my-table">
<!--main division-->
<div style="overflow-x:auto;">
<table>
<tr>
<th></th>
<th>test</th>
<th>test</th>
<th>Free</th>
</tr>
<tr class="first">
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr>
<tr>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr>
<tr>
<td>test</td>
<td>test</td>
<td>test</td>
<td>test</td>
</tr>
</table>
</div>
</body>
</html>
As you can see in the snippet above, my table give back the border color but when I try it in my web the color itself is gone, even I put it the code and the css like I make in the snippet the color is lost
can someone help me to solve this? or tell me what's wrong with my code
If you want to get the table border then please modify the below css:
#my-table table {
border: none; // Remove this line
border-top: none; // Remove this line
border: 1px solid red; // Add this line
}

Align table header text with table body text?

I just can't figure how to align the text in the header on the left together with the text in body header. The table is a scrollable table.
.container {
padding-left:260px;
table-layout: fixed;
text-align: left;
}
.tableheader{
background-color: rgba(255, 255, 255, 0.3);
width: 1000px;
}
.tablecontent{
height: 100px;
width: 1000px;
overflow-x: auto;
margin-top: 0px;
border: 1px solid rgba(255,255,255,0.3);
}
th{
font-weight: 500;
font-size: 12px;
color: rgb(68, 68, 68);
text-transform: uppercase;
padding: 20px;
width: 100px;
}
td{
padding: 15px;
width: 100px;
vertical-align:middle;
font-weight: 300;
font-size: 12px;
color: rgb(59, 59, 59);
border-bottom: solid 1px rgba(255,255,255,0.1);
}
::-webkit-scrollbar {
width: 6px;
}
::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
}
::-webkit-scrollbar-thumb {
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
}
<section class="container">
<div class="tableheader" >
<table cellpadding="0" cellspacing="0" border="0">
<thead>
<tr>
<th>Username</th>
<th>Name</th>
<th>Position</th>
<th>Status</th>
<th>Time</th>
<th>Date</th>
</tr>
</thead>
</table>
</div>
<div class="tablecontent">
<table cellpadding="0" cellspacing="0" border="0">
<tbody class="tablecontent">
<?php echo $stafftable?>
</tbody>
</table>
</div>
</section>
As you can see the table header text alignment is different from table body alignment. I can't seem to find what is the problem. I have tried editing the padding and the width of th and tr.
It is beacause you have set the different padding of th and td.
try this:
.container {
padding-left:260px;
table-layout: fixed;
text-align: left;
}
.tableheader{
background-color: rgba(255, 255, 255, 0.3);
width: 1000px;
}
.tablecontent{
height: 100px;
width: 1000px;
overflow-x: auto;
margin-top: 0px;
border: 1px solid rgba(255,255,255,0.3);
}
th{
font-weight: 500;
font-size: 12px;
color: rgb(68, 68, 68);
text-transform: uppercase;
padding: 15px;
width: 100px;
}
td{
padding: 15px;
width: 100px;
vertical-align:middle;
font-weight: 300;
font-size: 12px;
color: rgb(59, 59, 59);
border-bottom: solid 1px rgba(255,255,255,0.1);
}
::-webkit-scrollbar {
width: 6px;
}
::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
}
::-webkit-scrollbar-thumb {
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
<section class="container">
<div class="tableheader" >
<table cellpadding="0" cellspacing="0" border="0">
<thead>
<tr>
<th align="left">Username</th>
<th>Name</th>
<th>Position</th>
<th>Status</th>
<th>Time</th>
<th>Date</th>
</tr>
</thead>
</table>
</div>
<div class="tablecontent">
<table cellpadding="0" cellspacing="0" border="0">
<tbody class="tablecontent">
<tr>
<td>Username</td>
<td>Name</td>
<td>Position</td>
<td>Status</td>
<td>Time</td>
<td>Date</td>
</tr>
</tbody>
</table>
</div>
</section>
Adjust your td padding property to match this of the th. In your example, td had padding 15px and th had 20px. It's responsible for the left indentation, so adjust it to be the same. In my example below it is set to 20px. Consider doing it in one place, like
td, th { padding: 20px; }
Working example:
.container {
padding-left:260px;
table-layout: fixed;
text-align: left;
}
.tableheader{
background-color: rgba(255, 255, 255, 0.3);
width: 1000px;
}
.tablecontent{
height: 100px;
width: 1000px;
overflow-x: auto;
margin-top: 0px;
border: 1px solid rgba(255,255,255,0.3);
}
th{
font-weight: 500;
font-size: 12px;
color: rgb(68, 68, 68);
text-transform: uppercase;
padding: 20px;
width: 100px;
}
td{
padding: 20px; /* CHANGED FROM 15PX TO 20PX */
width: 100px;
vertical-align:middle;
font-weight: 300;
font-size: 12px;
color: rgb(59, 59, 59);
border-bottom: solid 1px rgba(255,255,255,0.1);
}
::-webkit-scrollbar {
width: 6px;
}
::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
}
::-webkit-scrollbar-thumb {
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
}
<section class="container">
<div class="tableheader" >
<table cellpadding="0" cellspacing="0" border="0">
<thead>
<tr>
<th>Username</th>
<th>Name</th>
<th>Position</th>
<th>Status</th>
<th>Time</th>
<th>Date</th>
</tr>
</thead>
</table>
</div>
<div class="tablecontent">
<table cellpadding="0" cellspacing="0" border="0">
<tbody class="tablecontent">
<tr>
<td>Username</td>
<td>Name</td>
<td>Position</td>
<td>Status</td>
<td>Time</td>
<td>Date</td>
</tr>
<tr>
<td>Username</td>
<td>Name</td>
<td>Position</td>
<td>Status</td>
<td>Time</td>
<td>Date</td>
</tr>
<tr>
<td>Username</td>
<td>Name</td>
<td>Position</td>
<td>Status</td>
<td>Time</td>
<td>Date</td>
</tr>
<tr>
<td>Username</td>
<td>Name</td>
<td>Position</td>
<td>Status</td>
<td>Time</td>
<td>Date</td>
</tr>
</tbody>
</table>
</div>
</section>

Responsive Email Template positioning Issues

I am trying to create a responsive HTML email template but I am having a little trouble figuring out how to get my elements to position themselves they way I want.
In my code below, you will see I have an image next to some text.
When the screen gets to a small size (< 700px) I want the image to go above the text. Not below like it currently does.
The current header section will not center over the entire row. It stays more left aligned:
<tr>
<td align="center">
<h3>Thank you for reserving your deal with us!</h3>
</td>
</tr>
Same goes for my horizontal row:
<tr>
<td>
<hr>
</td>
</tr>
I can visually see the tr takes the whole width but the elements will not expand to fill them. Why is that?
My code:
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
background-color: #e7e7e7;
}
#parentTable {
background-color: fff;
margin: auto;
border-bottom: 10px solid #007dc3;
-moz-box-shadow: 0px 3px 15px rgba(0, 0, 0, 0.2);
-webkit-box-shadow: 0px 3px 15px rgba(0, 0, 0, 0.2);
box-shadow: 0px 3px 15px rgba(0, 0, 0, 0.2);
}
td {
padding: 10px;
}
.row td {
padding: 10px 20px;
}
.para {
font-family: inherit;
line-height: 22px;
font-weight: 300;
color: #3b3b3b
}
.btn {
display: inline-block;
padding: 6px 12px;
margin-bottom: 0;
font-size: 14px;
font-weight: 400;
line-height: 1.42857143;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-image: none;
border: 1px solid transparent;
border-radius: 3px;
-moz-box-shadow: 0px 3px 15px rgba(0, 0, 0, 0.2);
-webkit-box-shadow: 0px 3px 15px rgba(0, 0, 0, 0.2);
box-shadow: 0px 3px 15px rgba(0, 0, 0, 0.2);
}
.code {
background-color: #007dc3;
color: white;
box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.2);
-webkit-box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.2);
}
.code td {
padding: 10px;
text-align: center;
}
.view-deal-button {
color: fff;
background-color: #007dc3;
font-family: inherit;
font-size: 15px;
}
.vehilce-img {
position: relative;
}
.vehicle-img img {
width: 400px;
}
.contact {
font-size: 15px;
padding: 5px;
}
#trademark {
text-align: center;
padding: 8px;
font-size: 9px;
margin: auto;
color: #3b3b3b;
}
#media only screen and (max-width: 700px) {
.wrapper table {
width: 100%;
}
.wrapper .column {
width: 100%;
display: block;
}
}
<table id="parentTable" width="100%" style="background: #fff">
<tr>
<td class="wrapper" width="600" align="center">
<table cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<h3>Thank you for reserving your deal with us!</h3>
</td>
</tr>
<tr>
<td class="column" width="600">
<table>
<tr class="code">
<td>
Your Personalised Code: <b>JNk1u7</b>
</td>
</tr>
<tr class="row">
<td class="para">
Please bring a printed copy of this email or simply note your personalized deal code so you have this information when you come in to pick up
</td>
</tr>
<tr class="row">
<td align="center">
<button class="view-deal-button btn" type='button'>View Your Deal</button>
</td>
</tr>
<tr class="row">
<td class="para">
Please feel free to be in touch, confirm any details of the deal, or ask any questions you may have. We look forward to meeting you soon!
</td>
</tr>
<tr>
<td class="para">
John Smith<br> General Sales Manager<br>
</td>
</tr>
</table>
</td>
<td class="column" width="300">
<table>
<tr>
<td align="center" class="vehicle-img">
<img src="https://092a1aab381dd581da25-7ddb065c39b8a73e05c6a8bc02fc8661.ssl.cf1.rackcdn.com//thumbnails/3HGGK5G43JM718575/9c127e805481e2ed1b5b17dde1621d92.jpg">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<hr>
</td>
</tr>
</table>
</td>
</tr>
</table>
View on JSFiddle
I'll address your second point first. The table inside .wrapper has two columns (class="column"), but the first and last rows have only one column and they are not set to span two. That causes problems with the table layout. Here's an example using colspan:
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
background-color: #e7e7e7;
}
#parentTable {
background-color: fff;
margin: auto;
border-bottom: 10px solid #007dc3;
-moz-box-shadow: 0px 3px 15px rgba(0, 0, 0, 0.2);
-webkit-box-shadow: 0px 3px 15px rgba(0, 0, 0, 0.2);
box-shadow: 0px 3px 15px rgba(0, 0, 0, 0.2);
}
td {
padding: 10px;
}
.row td {
padding: 10px 20px;
}
.para {
font-family: inherit;
line-height: 22px;
font-weight: 300;
color: #3b3b3b
}
.btn {
display: inline-block;
padding: 6px 12px;
margin-bottom: 0;
font-size: 14px;
font-weight: 400;
line-height: 1.42857143;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-image: none;
border: 1px solid transparent;
border-radius: 3px;
-moz-box-shadow: 0px 3px 15px rgba(0, 0, 0, 0.2);
-webkit-box-shadow: 0px 3px 15px rgba(0, 0, 0, 0.2);
box-shadow: 0px 3px 15px rgba(0, 0, 0, 0.2);
}
.code {
background-color: #007dc3;
color: white;
box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.2);
-webkit-box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.2);
}
.code td {
padding: 10px;
text-align: center;
}
.view-deal-button {
color: fff;
background-color: #007dc3;
font-family: inherit;
font-size: 15px;
}
.vehilce-img {
position: relative;
}
.vehicle-img img {
width: 400px;
}
.contact {
font-size: 15px;
padding: 5px;
}
#trademark {
text-align: center;
padding: 8px;
font-size: 9px;
margin: auto;
color: #3b3b3b;
}
#media only screen and (max-width: 700px) {
.wrapper table {
width: 100%;
}
.wrapper .column {
width: 100%;
display: block;
}
}
<table id="parentTable" width="100%" style="background: #fff">
<tr>
<td class="wrapper" width="600" align="center">
<table cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" align="center">
<h3>Thank you for reserving your deal with us!</h3>
</td>
</tr>
<tr>
<td class="column" width="600">
<table>
<tr class="code">
<td>
Your Personalised Code: <b>JNk1u7</b>
</td>
</tr>
<tr class="row">
<td class="para">
Please bring a printed copy of this email or simply note your personalized deal code so you have this information when you come in to pick up
</td>
</tr>
<tr class="row">
<td align="center">
<button class="view-deal-button btn" type='button'>View Your Deal</button>
</td>
</tr>
<tr class="row">
<td class="para">
Please feel free to be in touch, confirm any details of the deal, or ask any questions you may have. We look forward to meeting you soon!
</td>
</tr>
<tr>
<td class="para">
John Smith<br> General Sales Manager<br>
</td>
</tr>
</table>
</td>
<td class="column" width="300">
<table>
<tr>
<td align="center" class="vehicle-img">
<img src="https://092a1aab381dd581da25-7ddb065c39b8a73e05c6a8bc02fc8661.ssl.cf1.rackcdn.com//thumbnails/3HGGK5G43JM718575/9c127e805481e2ed1b5b17dde1621d92.jpg">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2">
<hr>
</td>
</tr>
</table>
</td>
</tr>
</table>
For your first point, I recommend restructuring to use a flexible box layout so that you can leverage flex-direction to reverse the element order at put the image first. Here's my suggestion:
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
background-color: #e7e7e7;
margin: 0;
}
#container {
display: flex;
flex-direction: row;
justify-content: space-between;
}
#container>div {
flex: 0 0 50%;
padding: 1em;
box-sizing: border-box;
text-align: center;
}
h3 {
text-align: center;
}
p {
text-align: left;
}
.responsive_image {
max-width: 100%;
}
.code {
background-color: #007dc3;
color: white;
box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.2);
padding: 1em;
text-align: center;
}
.btn {
display: inline-block;
padding: 6px 12px;
font-size: 14px;
font-weight: 400;
line-height: 1.42857143;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-image: none;
border: 1px solid transparent;
border-radius: 3px;
box-shadow: 0px 3px 15px rgba(0, 0, 0, 0.2);
}
.view-deal-button {
color: fff;
background-color: #007dc3;
font-family: inherit;
font-size: 15px;
}
#media only screen and (max-width: 700px) {
#container {
flex-direction: column-reverse;
}
}
<h3>Thank you for reserving your deal with us!</h3>
<div id="container">
<div>
<p class="code">Your Personalised Code: <b>JNk1u7</b></p>
<p>Please bring a printed copy of this email or simply note your personalized deal code so you have this information when you come in to pick up.</p>
<button class="view-deal-button btn" type='button'>View Your Deal</button>
<p>Please feel free to be in touch, confirm any details of the deal, or ask any questions you may have. We look forward to meeting you soon!</p>
<p>John Smith<br>General Sales Manager</p>
</div>
<div>
<img src="https://092a1aab381dd581da25-7ddb065c39b8a73e05c6a8bc02fc8661.ssl.cf1.rackcdn.com//thumbnails/3HGGK5G43JM718575/9c127e805481e2ed1b5b17dde1621d92.jpg" class="responsive_image">
</div>
</div>
I realize that this method may not be reliable for email templates. In that case, you might be able to put the image first in your code and float it to the right on desktop.

Can't seem to make an A tag fill parent TD tag

I am trying to make an A tag fill the parent TD element. However, no matter what I try it doesn't seem to work.
I have viewed many various other Stack Overflow pages and they all state to do
child-element{
display: block;
width: 100%;
}
But this has not seemed to work in my case.
html {
font-family: "Times New Roman", Times, serif;
color: white;
}
#wrapper {
background-color: black;
background: #50a3a2;
background: -webkit-linear-gradient(top left, #50a3a2 0%, #53e3a6 100%);
background: linear-gradient(to bottom right, #50a3a2 0%, #53e3a6 100%);
}
a {
color: white;
text-decoration: none;
background-color: none;
cursor: pointer;
}
#wrapper,
#header,
#main {
padding: 10px 15px;
margin: 0 auto 10px auto;
text-align: center;
border: 1px solid rgba(255, 255, 255, 0.4);
background-color: rgba(255, 255, 255, 0.2);
}
#header {
min-width: 40vw;
max-width: 50vw;
}
#main {
min-height: 65vh;
}
.nav-link {
float: left;
padding: 10px 15px;
margin: 0 5px 0 5px;
border: 1px solid rgba(255, 255, 255, 0.4);
background-color: rgba(255, 255, 255, 0.2);
}
.nav-link:hover {
background-color: rgba(255, 255, 255, 0.4);
}
.nav-link a {
display: block;
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, 0.3);
}
<body>
<div id="wrapper">
<div id="header">
<table align="center">
<td class="nav-link">Main</td>
<td class="nav-link">Test</td>
<td class="nav-link">FAQ</td>
</table>
</div>
<div id="main">
<h1 style="line-height: 0%">Header</h1>
<p style="line-height: 0%; font-size: 1vw">_________________________________________________________________________________________________________</p>
<br>
<br>
</div>
</div>
</body>
If you would like to see this displayed you can view here: https://jsfiddle.net/wverhe/8gcypffm/
Remove the padding from .nav-link and add it to the .nav-link a. You can also remove the width and height from links since they will get resized from the padding.
html {
font-family: "Times New Roman", Times, serif;
color: white;
}
#wrapper {
background-color: black;
background: #50a3a2;
background: -webkit-linear-gradient(top left, #50a3a2 0%, #53e3a6 100%);
background: linear-gradient(to bottom right, #50a3a2 0%, #53e3a6 100%);
}
a {
color: white;
text-decoration: none;
background-color: none;
cursor: pointer;
}
#wrapper,
#header,
#main {
padding: 10px 15px;
margin: 0 auto 10px auto;
text-align: center;
border: 1px solid rgba(255, 255, 255, 0.4);
background-color: rgba(255, 255, 255, 0.2);
}
#header {
min-width: 40vw;
max-width: 50vw;
}
#main {
min-height: 65vh;
}
.nav-link {
float: left;
margin: 0 5px 0 5px;
border: 1px solid rgba(255, 255, 255, 0.4);
background-color: rgba(255, 255, 255, 0.2);
}
.nav-link:hover {
background-color: rgba(255, 255, 255, 0.4);
}
.nav-link a {
display: block;
padding: 10px 15px;
/* width: 100%; */
/* height: 100%; */
background-color: rgba(255, 255, 255, 0.3);
}
<body>
<div id="wrapper">
<div id="header">
<table align="center">
<td class="nav-link">Main</td>
<td class="nav-link">Test</td>
<td class="nav-link">FAQ</td>
</table>
</div>
<div id="main">
<h1 style="line-height: 0%">Header</h1>
<p style="line-height: 0%; font-size: 1vw">_________________________________________________________________________________________________________</p>
<br>
<br>
</div>
</div>
</body>
https://jsfiddle.net/8gcypffm/4/