Trying to center 2 responsive tables on center of page - css

For some reason these 2 tables won't center, I tried the bootstrap container class, tried margin 0 auto. But they won't center smack in the middle, any idea?
I want both tables centered and displayed horizontally in the middle side by side.
It's on codepen over here:
enter link description here
http://codepen.io/Satearn/pen/ybvXLR
.z
{position :absolute ;
top:50%;
left:50%;
transform :translate(-50%,-50%) ;}

To centre align them just remove width: 100%; from your following CSS code.
.table-fill {
background: white;
border-radius:3px;
border-collapse: collapse;
height: 320px;
margin: auto;
max-width: 300px;
padding:5px;
width: 100%;
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
animation: float 5s infinite;
}

Like this? I used Bootstrap. And I reduced the data inside the table for simplicity
html {
background-color: #3e94ec;
}
/*** Table Styles **/
.table-fill {
border-radius: 3px;
border-collapse: collapse;
padding: 5px;
}
th {
color: #D5DDE5;
background: #1b1e24;
border-bottom: 4px solid #9ea7af;
border-right: 1px solid #343a45;
font-size: 23px;
font-weight: 100;
padding: 24px;
text-align: left;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
vertical-align: middle;
}
th:first-child {
border-top-left-radius: 3px;
}
th:last-child {
border-top-right-radius: 3px;
border-right: none;
}
tr {
border-top: 1px solid #C1C3D1;
border-bottom-: 1px solid #C1C3D1;
color: #666B85;
font-size: 16px;
font-weight: normal;
text-shadow: 0 1px 1px rgba(256, 256, 256, 0.1);
}
tr:hover td {
background: #4E5066;
color: #FFFFFF;
border-top: 1px solid #22262e;
border-bottom: 1px solid #22262e;
}
tr:first-child {
border-top: none;
}
tr:last-child {
border-bottom: none;
}
tr:nth-child(odd) td {
background: #EBEBEB;
}
tr:nth-child(odd):hover td {
background: #4E5066;
}
tr:last-child td:first-child {
border-bottom-left-radius: 3px;
}
tr:last-child td:last-child {
border-bottom-right-radius: 3px;
}
td {
background: #FFFFFF;
padding: 20px;
text-align: left;
vertical-align: middle;
font-weight: 300;
font-size: 18px;
text-shadow: -1px -1px 1px rgba(0, 0, 0, 0.1);
border-right: 1px solid #C1C3D1;
}
td:last-child {
border-right: 0px;
}
th.text-left {
text-align: left;
}
th.text-center {
text-align: center;
}
th.text-right {
text-align: right;
}
td.text-left {
text-align: left;
}
td.text-center {
text-align: center;
}
td.text-right {
text-align: right;
}
.middlepage {
margin: 0 auto;
}
#outer-cont {
text-align: center;
}
#target-element-to-center {
display: inline-block;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="row">
<table class="table-fill col-xs-6" id="a">
<thead>
<tr>
<th class="text-center" colspan="2">Month</th>
</tr>
</thead>
<tbody class="table-hover">
<tr>
<td class="text-left">January</td>
<td class="text-left">$ 50,000.00</td>
</tr>
</tbody>
</table>
<table class="table-fill col-xs-6" id="a">
<thead>
<tr>
<th class="text-center" colspan="2">Strategies</th>
</tr>
</thead>
<tbody class="table-hover">
<tr>
<td class="text-left">January</td>
<td class="text-left">$ 50,000.00</td>
</tr>
</tbody>
</table>
</div>
</div>

Related

How to overlap box-shadows on table rows?

I have a table on which I want to highlight a number of successive rows (TR's) by applying a box-shadow around them.
My strategy was to apply a class called "selected-top" to the first row of the selection, classes "selected-middle" for the middle part, and "selected-bottom" for the last row.
However, the shadows of the middle rows bleed over. I tried to rectify this by using z-index (I know that I have to add a relative property with that, so I did), but they seem to have no effect:
Here's the code:
tr.selected-top {
box-shadow: -5px -5px 5px #000, 5px -5px 5px #000;
position: relative;
z-index:10;
}
tr.selected-middle {
box-shadow: -5px 0px 5px #000, 5px 0px 5px #000;
position: relative;
z-index: -1;
}
The table is just a regular table:
<table>
<tr><td>stuff</td></tr>
<tr class="selected-top"><td>highlighting starts</td></tr>
<tr class="selected-middle"><td>highlighting middle</td></tr>
<tr class="selected-bottom"><td>highlighting end</td></tr>
<tr><td>other stuff</td></tr>
</table>
What am I doing wrong?
By the way, I did try to only apply a shadow to only the sides for the middle rows, but that way the shadow is not continuous.
Update: #Aditya Toke, like so: (left is wrong shading, right is correct shading)
You can achieve it using ::before and ::after pseudo elements to mask the top and bottom shadow from "middle" row.
The height of the pseudo elements is set exactly equal to the length of the shadow for masking and is absolute position.
Since the shadow hides the top borders of selected-bottom and it's next sibling element we need to add them back as:
tr.selected-middle td,
tr.selected-bottom td {
border-bottom: 1px solid #666;
}
body {
background-color: #1b1b1b;
margin: 20px;
}
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: auto;
box-sizing: border-box;
border: none;
margin: auto;
}
tr { display: block; }
tr, td {
height: 50px;
background: #333;
color: #eee;
}
td {
padding-left: 16px;
min-width: 170px;
width: 100%;
border-top: 1px solid #666;
}
tr.selected-top {
position: relative;
box-shadow: -5px -5px 5px #000, 5px -5px 5px #000;
}
tr.selected-middle {
position: relative;
box-shadow: 0px 0px 5px 5px #000;
}
tr.selected-bottom {
position: relative;
box-shadow: 5px 5px 5px #000, -5px 5px 5px #000;
}
tr.selected-middle ::before,
tr.selected-middle ::after {
pointer-events: none;
position: absolute;
content:" ";
background-color: #333;
left: 0;
width: 100%;
}
tr.selected-middle ::before {
height: 10px;
top: -10px;
}
tr.selected-middle ::after {
top: calc(100% + 4px);
height: 5px;
}
tr.selected-middle td,
tr.selected-bottom td {
border-bottom: 1px solid #666;
}
<table>
<tbody>
<tr>
<td>Some stuffs</td>
</tr>
<tr class="selected-top">
<td>highlighting starts</td>
</tr>
<tr class="selected-middle">
<td>highlighting middle</td>
</tr>
<tr class="selected-bottom">
<td>highlighting ends</td>
</tr>
<tr>
<td>Some stuffs</td>
</tr>
</tbody>
</table>
table {
height: 67vh;
width: 59vw;
background-color: #333333;
}
td {
/* background-color: #333333; */
color: white;
}
div {
display: flex;
justify-content: center;
align-items: center;
}
.div1 {
box-shadow: -5px -5px 5px #000, 5px -5px 5px #000;
height: 100%;
border: 1px solid darkgrey;
border-left: 0;
border-right: 0;
}
.div2 {
box-shadow: -4px 0px 2px 0.5px #000, 2px 0px 0.5px 0.5px #000, 5px 0.5px 3px 0px #000;
height: 100%;
border: 1px solid #333333;
}
.div3 {
box-shadow: -6px 3px 5px #000, 6px 5px 6px 1px #000;
height: 100%;
position: relative;
border: 1px solid darkgrey;
border-left: 0;
border-right: 0;
}
<!DOCTYPE html>
<html lang="en">
<body>
<table>
<tr>
<td>stuff</td>
</tr>
<tr class="selected-top">
<td>
<div class="div1">
highlighting starts
</div>
</td>
</tr>
<tr class="selected-middle">
<td>
<div class="div2">
highlighting middle
</div>
</td>
</tr>
<tr class="selected-bottom">
<td>
<div class="div3">
highlighting end
</div>
</td>
</tr>
<tr>
<td>other stuff</td>
</tr>
</table>
</body>
</html>
I tried to create similar to what you have provided in the expected output

Get Rid Of Blank Space due to box-sizing property of parent element

I am creating a table and I have used box-sizing: border-box; property for its parent element body. I'm getting a vertical red line on the right in Chrome for some screen resolutions (try to zoom in and out to see it). I want to get rid of this red line.
When I remove the box-sizing: border-box; property from the body it works fine. But it changes the appearance of other elements. Is there a way to get rid of it.
UPDATE:
I want to create a table with the following requirements:
1. Responsive design i.e. horizontal scroll instead of line wrap or overflow.
2. Width 100%.
3. Box-shadow.
4. And it does not distort other element.
Here, is my code:
body {
border-radius: 4px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
box-sizing: border-box;
color: rgba(0, 0, 0, 0.87);
font: 400 1rem 'Roboto', sans-serif;
margin: 2vh auto;
min-height: 96vh;
padding: 40px;
width: 72vw;
}
table {
background-color: red;
border-collapse: collapse;
border-radius: 4px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
display: block;
overflow-x: auto;
}
tbody {
background-color: blue;
display: table;
width: 100%;
}
tr:not(:first-child):hover {
background-color: #F5F5F5/* [Gray -> 200] */
}
th {
color: #616161;
/* [Gray -> 700] */
font-size: 0.9rem;
padding: 16px;
text-align: left;
}
td {
border-top: 1px solid #E0E0E0;
/* [Gray -> 300] */
padding: 8px 16px;
}
<body>
<table>
<tr>
<th>Name</th>
<th>Field</th>
<th>Class</th>
</tr>
<tr>
<td>Mansoor</td>
<td>Science</td>
<td>XI-B</td>
</tr>
<tr>
<tr>
<td>Manny</td>
<td>Science</td>
<td>XI-B</td>
</tr>
<tr>
<td>Joe</td>
<td>Science</td>
<td>XI-B</td>
</tr>
<tr>
<td>John</td>
<td>Science</td>
<td>XI-C</td>
</tr>
</table>
</body>
This is an interesting case. First of all, I'd say this is a quirk due to semantically wrong usage of styles: these bits
table {
display: block;
}
tbody {
display: table;
}
make no sense, why would you use that?
I've tweaked this a bit and created an MCVE:
table {
display: block;
background-color: red;
}
tbody {
display: table;
width: 100%;
background-color: #ccffff;
}
<table>
<tr>
<td>test</td>
</tr>
</table>
On zooming in and out in Chrome one may see the vertical red line on the right.
As we can see, the width of an element with display: table; width: 100%; is not accurately calculated by the browser when it is inside an element with display: block. To illustrate that this is the root of the problem, consider 2 more snippets:
.table {
background-color: red;
display: block;
}
.tbody {
background-color: #ccf8ff;
display: table;
width: 100%;
}
.tr {
display: table-row;
}
.td {
display: table-cell;
}
<div class="table">
<div class="tbody">
<div class="tr">
<div class="td">test</div>
</div>
</div>
</div>
this is the structure of the "table" as you modified it. The cell doesn't actually play any role, this still reproduces the issue:
.table {
background-color: red;
display: block;
}
.tbody {
background-color: #ccf8ff;
display: table;
width: 100%;
}
<div class="table">
<div class="tbody">
test
</div>
</div>
I think this may be considered as a browser bug, but since this structure is semantically wrong, you can't call it a bug really since specs probably don't say anything about it.
Just remove those display rules and move width: 100% to the table, and here you go:
body {
border-radius: 4px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
box-sizing: border-box;
color: rgba(0, 0, 0, 0.87);
font: 400 1rem 'Roboto', sans-serif;
margin: 2vh auto;
min-height: 96vh;
padding: 40px;
width: 72vw;
}
table {
background-color: red;
border-collapse: collapse;
border-radius: 4px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
overflow-x: auto;
width: 100%;
}
tbody {
background-color: blue;
}
tr:not(:first-child):hover {
background-color: #F5F5F5/* [Gray -> 200] */
}
th {
color: #616161;
/* [Gray -> 700] */
font-size: 0.9rem;
padding: 16px;
text-align: left;
}
td {
border-top: 1px solid #E0E0E0;
/* [Gray -> 300] */
padding: 8px 16px;
}
<body>
<table>
<tr>
<th>Name</th>
<th>Field</th>
<th>Class</th>
</tr>
<tr>
<td>Mansoor</td>
<td>Science</td>
<td>XI-B</td>
</tr>
<tr>
<tr>
<td>Manny</td>
<td>Science</td>
<td>XI-B</td>
</tr>
<tr>
<td>Joe</td>
<td>Science</td>
<td>XI-B</td>
</tr>
<tr>
<td>John</td>
<td>Science</td>
<td>XI-C</td>
</tr>
</table>
</body>

Rails: How to make table and image side by side

In my current code, an image that is uploaded is on top of the table, but since the layout of the website I'm creating is so wide, I want to put the image next to the table, how do I fix my code to make that happen?
My show file
<body>
<div class = "head1">
<h1>Inventory Information</h1>
<div class = "image1" >
<img src= "http://dx.deucex.com/i/logo.png" >
</div>
</div>
</body>
<aside>
<%= render #inventory.photos %>
<h3>Add a photo:</h3>
<%= render 'photos/form' %>
<div class = "inventory_border" >
<table>
<tr>
<p>
<td><strong>Product Name:</strong></td>
<td><%= #inventory.product_name %></td>
</p>
</tr>
<tr>
<p>
<td><strong>Brand Name:</strong></td>
<td><%= #inventory.brand_name %></td>
</p>
</tr>
#more code...
</table>
</div>
<%= link_to 'Back', inventories_path %>
</aside>
css
body
{
background: #e6f2ff;
}
input[type=text]{
width: 20%;
padding: 12px 12px;
border: 2px solid #ccc;
background-color: white;
}
textarea {
width: 20%;
height: 10px;
padding: 12px 12px;
border: 2px solid #ccc;
background-color: white;
resize: none
}
h1{
background-color: #ccccff;
width: 400px;
height: 50px;
border: 7px solid #333333;
border-radius: 20px;
padding-left: 20px;
padding-top: 10px;
margin-left: 5px;
margin-top: 30px;
border-style: double;
}
.vend2{
background-color: white;
width: 1800px;
margin-left: -8px;
}
.invent{
background-color: white;
width: 1800px;
margin-left: -8px;
}
table{
width: 800px;
}
th{
background-color: #b3b3cc;
border-radius: 4px;
border: 2px solid black;
width: 365px;
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
}
input[type = buttton], input[type = submit], {
background-color: #ccddff;
border: solid;
border-radius: 3px;
color: black;
padding: 16px 20px;
text-decoration: none;
cursor: pointer;
}
input[type = buttton]:hover, input[type = submit]:hover, {
background-color: blue;
border: solid;
border-radius: 3px;
color: white;
padding: 16px 20px;
text-decoration: none;
cursor: pointer;
border-color:black;
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
}
h2{
background-color: red;
border: none;
width: 750px;
}
.head{
display:flex;
background-color: #e6e6e6;
min-width: 140%
}
.head1{
display:flex;
background-color: #e6e6e6;
min-width: 140%
}
div.head {
border-bottom: 3px outset black;
border-top: 30px outset gray;
margin-top: -50px;
margin-left: -8px;
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
margin-bottom: 60px;
}
div.head1 {
border-bottom: 3px outset black;
border-top: 30px outset gray;
margin-top: -50px;
margin-left: -8px;
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
margin-bottom: 60px;
}
div.header{
font-size: 40px;
margin-left: 50px;
}
div.image1{
margin-left: 100px;
}
.inventory_border{
border-top: 3px solid black;
max-width: 50%
}
.vendor_border{
border-top: 3px solid black;
max-width: 70%
}
div.field{
background-color: #e6e6e6;
max-width: 30%;
border: 1px solid black;
}
aside{
margin-left: 50px;
}
article{
margin-left: 800px;
border-left: 1px solid gray;
padding: 1em;
overflow: hidden;
}

css style - background color with image overlay on html table

I am trying to have a image, dynamically, overlay a table, that is opacity half filled so it is a little transparent, but I cannot even get the image to display over the color of the cells... I'm trying to do that first, then I'll add the code to the opacity.
Can you please tell me what I did wrong?
The CSS is in a file, but this is for an invoice, I want to overlay an image that shows paid, refunded, voided, pending, etc.
Here is the short CSS for this invoice:
.clearfix:after {
content: "";
display: table;
clear: both;
}
a {
color: #5D6975;
text-decoration: underline;
}
.fbody {
position: relative;
width: 21cm;
height: 29.7cm;
margin: 0 auto;
color: #001028;
background: #FFFFFF;
font-family: Arial, sans-serif;
font-size: 12px;
font-family: Arial;
border-style: solid;
border-width: 1px;
border-color: #001028;
}
header {
padding: 10px 0;
margin-bottom: 30px;
}
div.logo {
text-align: center;
}
//.logo img {
// width: 90px;
//}
.th1 {
border-top: 1px solid #5D6975;
border-bottom: 1px solid #5D6975;
color: #5D6975;
font-size: 2.4em;
line-height: 1.4em;
font-weight: normal;
text-align: center;
margin: 0 0 20px 0;
background: url('/images/2.0/dimension.png');
}
#project {
float: left;
margin-left: 20px;
}
#project span {
color: #5D6975;
text-align: left;
width: 52px;
margin-left: 20px;
display: inline-block;
font-size: 1em;
}
#tcompany {
margin-right: 20px;
float: right;
text-align: right;
}
#tcompany span {
color: #5D6975;
text-align: right;
width: 52px;
margin-right: 30px;
display: inline-block;
font-size: 1em;
}
#project div,
#tcompany div {
white-space: nowrap;
}
.ttable {
width: 100%;
border-collapse: collapse;
border-spacing: 0;
margin-bottom: 20px;
}
.ttable tr:nth-child(2n-1) td {
background: #F5F5F5;
color: #000000;
z-index: -1;
}
.ttable th,
.ttable td {
text-align: center;
color: #000000;
}
.ttable th {
padding: 5px 20px;
color: #000000;
border-bottom: 1px solid #C1CED9;
white-space: nowrap;
font-weight: normal;
}
.ttable .service,
.ttable .desc {
text-align: left;
}
.ttable td {
padding: 10px;
text-align: right;
color: #000000;
}
.ttable td.service,
.ttable td.desc {
vertical-align: top;
color: #000000;
}
.ttable td.unit,
.ttable td.qty,
.ttable td.total {
font-size: 1.2em;
color: #000000;
}
.ttable td.grand {
border-top: 1px solid #5D6975;
color: #000000;
}
// Shipment section
#toptable #billto {
padding-left: 10px;
margin-left: 10px;
margin-top: 0px;
padding-top: 0px;
vertical-align: top;
color: #000000;
}
#toptable #shipto {
padding-left: 10px;
margin-right: 10px;
margin-left: 10px;
padding-right: 10px;
padding-top: 0px;
margin-top: 0px;
vertical-align: top;
color: #000000;
}
#toptable .stable {
text-align: center;
padding: 0px;
color: #000000;
}
#toptable .stable2 {
text-align: center;
padding: 0px;
background: #EAFFEA;
color: #000000;
}
#toptable .stableheader {
font-weight: bold;
border-bottom: 1px; solid #5D6975;
background: #C0C0C0;
color: #000000;
text-align: center;
font-size: 1.3em;
height: 10px;
padding-top: 5px;
padding-bottom: 5px;
}
#notices .noticeheader {
color: #5D6975;
font-size: 1.5em;
margin-left: 20px;
}
#notices .notice {
color: #5D6975;
font-size: 1.2em;
margin-left: 20px;
}
footer {
color: #5D6975;
width: 100%;
height: 30px;
position: absolute;
bottom: 0;
border-top: 1px solid #C1CED9;
padding: 8px 0;
text-align: center;
}
Of course the path would require the domain, I took it off though, because it is behind a login page. (Edited, I went and uploaded it to a forum image hosting site)
Here is the HTML that is output by the programming. The Style inside of the table tag is what is built dynamically based upon the status of the invoice.
<table class="ttable" style="background: url('http://s10.postimg.org/d2nvpi7eh/refunded.gif'); z-index: 1; background-repeat: no-repeat; background-position: center;">
<tr>
<th class="service">Item Number</th>
<th class="desc">Product Name</th>
<th>Unit Price</th>
<th>QTY</th>
<th>TOTAL</th>
</tr>
<tbody>
<tr><td class="service">PackageSKU</td> <td class="desc">Item Name / Short Desc</td> <td class="unit">$5.00</td> <td class="qty">1</td> <td class="total">$5.00</td></tr><tr><td class="service"> </td> <td class="desc"> </td> <td class="unit"> </td> <td class="qty"> </td> <td class="total"> </td></tr><tr><td class="service"> </td> <td class="desc"> </td> <td class="unit"> </td> <td class="qty"> </td> <td class="total"> </td></tr>
<tr>
<td colspan="4">SUBTOTAL</td>
<td class="total">$5.00</td>
</tr>
<tr>
<td colspan="4">Shipping and Handling</td>
<td class="total">$1.95</td>
</tr>
<tr>
<td colspan="4">TAX</td>
<td class="total">$0.00</td>
</tr>
<tr>
<td colspan="4" class="grand total">GRAND TOTAL</td>
<td class="grand total">$6.95</td>
</tr>
</tbody>
</table>
See, I tried to use the z-index, but it is not working.
The every other line has the background color in the css file, and it appears over the image.
The lines that do not have a background color, I can see the image, it just is not on top of the color.
Can you see how I need to fix it?
Edited again, I added a jsfiddle: http://jsfiddle.net/bizactuators/je26zszu/
sorry, the other one was not mine, had to register.
Another solution is to use negative z-index to td with background color:
.ttable tr:nth-child(2n-1) td {
background: #F5F5F5;
color: #000000;
position: relative;/*Add position relative*/
z-index: -1;/*Add negative z-index*/
}
.clearfix:after {
content:"";
display: table;
clear: both;
}
a {
color: #5D6975;
text-decoration: underline;
}
.fbody {
position: relative;
width: 21cm;
height: 29.7cm;
margin: 0 auto;
color: #001028;
background: #FFFFFF;
font-family: Arial, sans-serif;
font-size: 12px;
font-family: Arial;
border-style: solid;
border-width: 1px;
border-color: #001028;
}
header {
padding: 10px 0;
margin-bottom: 30px;
}
div.logo {
text-align: center;
}
//.logo img {
// width: 90px;
//
}
.th1 {
border-top: 1px solid #5D6975;
border-bottom: 1px solid #5D6975;
color: #5D6975;
font-size: 2.4em;
line-height: 1.4em;
font-weight: normal;
text-align: center;
margin: 0 0 20px 0;
background: url('/images/2.0/dimension.png');
}
#project {
float: left;
margin-left: 20px;
}
#project span {
color: #5D6975;
text-align: left;
width: 52px;
margin-left: 20px;
display: inline-block;
font-size: 1em;
}
#tcompany {
margin-right: 20px;
float: right;
text-align: right;
}
#tcompany span {
color: #5D6975;
text-align: right;
width: 52px;
margin-right: 30px;
display: inline-block;
font-size: 1em;
}
#project div, #tcompany div {
white-space: nowrap;
}
.ttable {
width: 100%;
border-collapse: collapse;
border-spacing: 0;
margin-bottom: 20px;
}
table.ttable{
background: url('http://s10.postimg.org/d2nvpi7eh/refunded.gif');
z-index: 1;
background-repeat: no-repeat;
background-position: center;
}
.ttable tr:nth-child(2n-1) td {
background: #F5F5F5;
color: #000000;
position: relative;
z-index: -1;
}
.ttable th, .ttable td {
text-align: center;
color: #000000;
}
.ttable th {
padding: 5px 20px;
color: #000000;
border-bottom: 1px solid #C1CED9;
white-space: nowrap;
font-weight: normal;
}
.ttable .service, .ttable .desc {
text-align: left;
}
.ttable td {
padding: 10px;
text-align: right;
color: #000000;
}
.ttable td.service, .ttable td.desc {
vertical-align: top;
color: #000000;
}
.ttable td.unit, .ttable td.qty, .ttable td.total {
font-size: 1.2em;
color: #000000;
}
.ttable td.grand {
border-top: 1px solid #5D6975;
color: #000000;
}
// Shipment section #toptable #billto {
padding-left: 10px;
margin-left: 10px;
margin-top: 0px;
padding-top: 0px;
vertical-align: top;
color: #000000;
}
#toptable #shipto {
padding-left: 10px;
margin-right: 10px;
margin-left: 10px;
padding-right: 10px;
padding-top: 0px;
margin-top: 0px;
vertical-align: top;
color: #000000;
}
#toptable .stable {
text-align: center;
padding: 0px;
color: #000000;
}
#toptable .stable2 {
text-align: center;
padding: 0px;
background: #EAFFEA;
color: #000000;
}
#toptable .stableheader {
font-weight: bold;
border-bottom: 1px;
solid #5D6975;
background: #C0C0C0;
color: #000000;
text-align: center;
font-size: 1.3em;
height: 10px;
padding-top: 5px;
padding-bottom: 5px;
}
#notices .noticeheader {
color: #5D6975;
font-size: 1.5em;
margin-left: 20px;
}
#notices .notice {
color: #5D6975;
font-size: 1.2em;
margin-left: 20px;
}
footer {
color: #5D6975;
width: 100%;
height: 30px;
position: absolute;
bottom: 0;
border-top: 1px solid #C1CED9;
padding: 8px 0;
text-align: center;
}
table.ttable > tr > td{
position: relative;
z-index: -1;
}
<table class="ttable">
<tr>
<th class="service">Item Number</th>
<th class="desc">Product Name</th>
<th>Unit Price</th>
<th>QTY</th>
<th>TOTAL</th>
</tr>
<tbody>
<tr>
<td class="service">PackageSKU</td>
<td class="desc">Item Name / Short Desc</td>
<td class="unit">$5.00</td>
<td class="qty">1</td>
<td class="total">$5.00</td>
</tr>
<tr>
<td class="service"> </td>
<td class="desc"> </td>
<td class="unit"> </td>
<td class="qty"> </td>
<td class="total"> </td>
</tr>
<tr>
<td class="service"> </td>
<td class="desc"> </td>
<td class="unit"> </td>
<td class="qty"> </td>
<td class="total"> </td>
</tr>
<tr>
<td colspan="4">SUBTOTAL</td>
<td class="total">$5.00</td>
</tr>
<tr>
<td colspan="4">Shipping and Handling</td>
<td class="total">$1.95</td>
</tr>
<tr>
<td colspan="4">TAX</td>
<td class="total">$0.00</td>
</tr>
<tr>
<td colspan="4" class="grand total">GRAND TOTAL</td>
<td class="grand total">$6.95</td>
</tr>
</tbody>
</table>
If you want to do that, you'll have to, as you correctly said, create an overlay. Something like this will do:
<div style="position: absolute;">
<div style="width: 100%; height: 100%; background-color: #000; opacity: 0.4; position: absolute; z-index: 10;"></div>
<table>
<thead><tr><th style="background-color: #f00;">Test<th></tr></thead>
<tbody>
<tr><td style="background-color: #f00;">Muh</td></tr>
<tr><td style="background-color: #f00;">Möp</td></tr>
<tr><td style="background-color: #f00;">Mäh</td></tr>
<tr><td style="background-color: #f00;">Muh</td></tr>
<tr><td style="background-color: #f00;">Möp</td></tr>
<tr><td style="background-color: #f00;">Mäh</td></tr>
</tbody>
</table>
</div>
I fix this try
.ttable tr:nth-child(2n-1) td {
background: transparent;
color: #000000;
}
Right?

Trouble changing the style on a table within a div statement

I created a table in HTML5 and used CSS to make it pretty. Then I decided to add a scroll bar and used webkit to change the style of that. Now after I used a div to get my scroll bar working it seems like my CSS code for the tbody,tr,thead,etc. are not working. I was wondering what I am doing wrong. I am positive that I am not calling the html table attributes correctly. I am very new to html5 and css but would really like to learn more.
Here is my code:
UPDATED 7/11/2013 9:36pm
CSS CODE
::-webkit-scrollbar {
width: 12px;
color:crimson;
background-color: black;
border-radius: 10px;
}
::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
border-radius: 10px;
background-color:black;
}
::-webkit-scrollbar-thumb {
border-radius: 10px;
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5);
background-color:gray;
}
.mytablecontainer #mytable{
width:500px;
border-collapse:separate;
background:crimson;
border-radius: 15px;
}
.mytablecontainer tbody {
overflow: auto;
height: 150px;
float: left;
width: 100%;
}
.mytablcontainer #mytable td {
text-align:center;
background:gray;
border-bottom:5px solid black;
border-radius: 15px;
}
.mytablecontainer #mytable th {
font-weight:bold;
text-align:center;
background:crimson;
border-bottom:5px solid black;
border-top-left-radius: 15px;
border-top-right-radius: 15px;
float: left;
width: 100%;
}
.mytablecontainer #mytable tr {
width: 100%;
display: table;
}
HTML5 CODE
<div class="mytablecontainer">
<table id="mytable">
<thead>
<tr>
<span>
Playlist
</span>
</tr>
</thead>
<tbody>
<tr>
<td> <span>
LINK 1
</span>
</td>
</tr>
<tr>
<td> <span>
LINK 2
</span>
</td>
</tr>
<tr>
<td> <span>
LINK 3
</span>
</td>
</tr>
<tr>
<td> <span>
LINK 4
</span>
</td>
</tr>
<tr>
<td> <span>
LINK 5
</span>
</td>
</tr>
<tr>
<td> <span>
LINK 6
</span>
</td>
</tr>
<tr>
<td> <span>
LINK 7
</span>
</td>
</tr>
</tbody>
</table>
</div>
.mytablcontainer #mytable.td {} remove "." dot before td and correct the spelling of your class
.mytablecontainer #mytable td {}
Demo
you do not need to call each time your main div selector try this css
::-webkit-scrollbar {
width: 12px;
color:crimson;
background-color: black;
border-radius: 10px;
}
::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
border-radius: 10px;
background-color:black;
}
::-webkit-scrollbar-thumb {
border-radius: 10px;
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5);
background-color:gray;
}
.mytablecontainer #mytable{
width:500px;
border-collapse:separate;
background:crimson;
border-radius: 15px;
}
#mytable tbody {
overflow: auto;
height: 150px;
float: left;
width: 100%;
}
#mytable td {
text-align:center;
background:gray;
border-bottom:5px solid black;
border-radius: 15px;
}
#mytable th {
font-weight:bold;
text-align:center;
background:crimson;
border-bottom:5px solid black;
border-top-left-radius: 15px;
border-top-right-radius: 15px;
float: left;
width: 100%;
}
#mytable tr {
width: 100%;
display: table;
}
for multiple attribute use this:
#mytable table, #mytable th, #mytable td {
border: 1px solid black;
border-collapse: collapse;
}

Resources