I have an HTML5 table with 3 header columns. They colspan=2 each, for a total of 6 columns wide. Under each header are 2 body columns that correspond to that header. I've got individual columns aligned left, but now I want the entire body center aligned so it lines up with the headers. I've tried the margin: 0 auto trick making sure I had a width defined and it's just not working.
Here is what it looks like now:
Here is my HTML:
<div id="areas">
<table>
<thead>
<tr>
<td colspan="2">Delaware County</td>
<td colspan="2">Main Line</td>
<td colspan="2">Chester County</td>
</tr>
</thead>
<tbody>
<tr>
<td class="city">Broomall</td>
<td class="zip">19008</td>
<td class="city">Ardmore</td>
<td class="zip">19003</td>
<td class="city">Paoli</td>
<td class="zip">19301</td>
</tr>
<tr>
<td class="city">Chester</td>
<td class="zip">19013</td>
<td class="city">Bala Cynwyd</td>
<td class="zip">19004</td>
<td class="city">Avondale</td>
<td class="zip">19311</td>
</tr>
<tr>
<td class="city">Aston</td>
<td class="zip">19014</td>
<td class="city">Bryn Mawr</td>
<td class="zip">19010</td>
<td class="city">Berwyn</td>
<td class="zip">19312</td>
</tr>
</tbody>
</table>
</div>
And my CSS:
#areas {
position: relative;
margin: 30px auto 60px auto;
width: 950px;
padding: 20px;
background-color: #4B004B;
-webkit-box-shadow: 11px 11px 15px rgba(50, 50, 50, 0.85);
-moz-box-shadow: 11px 11px 15px rgba(50, 50, 50, 0.85);
box-shadow: 11px 11px 15px rgba(50, 50, 50, 0.85);
border: 3px outset gold;
}
#areas thead td {
font-family: 'electricalregular';
-webkit-text-stroke: 1px orange;
letter-spacing: 2px;
font-size: 10pt;
font-weight: 100;
text-align: center;
width: 316px;
color: gold;
padding: 0 0 15px 0;
}
#areas tbody {
width: 950px;
margin: 0 auto;
}
#areas tbody td {
font-family: 'CommunistSans';
color: gold;
font-weight: 100;
padding: 0 0 5px 0px;
width: 158px;
}
#areas .zip {
text-align: left;
}
#areas .city {
text-align: left;
}
you could try
#areas .zip, #areas .city { position: relative; left: 30px; }
Related
I have table and inside this table button and textbox.
Here the code:
#dvStockCard{
border-style: solid;
border-width: thin;
padding: 12px 5px 5px 5px;
}
.title {
font-size: small;
border-top: 2px solid #686868;
color:#383838;
padding: 8px calc(100% - 10ch) 0px 0px;
}
/*----table styles----*/
#dvStockCard table{
font-family: sans-serif;
font-weight: 600;
border-collapse: collapse;
width: 100%;
font-size: x-small;
}
#dvStockCard table tr{
border-bottom: 2px solid lightgray;
color: #707070;
}
#dvStockCard table td {
padding: 8px;
}
#dvStockCard table tr td:nth-child(2) {
text-align: right;
}
/*------values styles------*/
.val{
font-size: small;
color: black;
}
#lastPrice{
font-family: 'Palatino Linotype';
font-size: 160%;
color:black;
}
#change{
font-family: 'Palatino Linotype';
font-size: 160%;
color:green;
}
.halfWidth{
position: relative;;
width:50%;
}
/*-------helpers styles--------*/
.spaceTop-10{
margin-top:10px
}
.spaceBottom-10{
margin-bottom:10px
}
.fullWidth{
width:100%;
}
.fullHeight{
height:100%;
}
<div id="dvStockCard">
<div class="title spaceBottom-10">My data cart</div>
<table>
<tr>
<td id="lastPrice">no price</td>
<td id="change">1234324t</td>
</tr>
<tr>
<td>Range</td>
<td id="range" class="val">No Rnge</td>
</tr>
<tr>
<td>Open</td>
<td id="open" class="val">555</td>
</tr>
<tr>
<td>Volume</td>
<td id="volume" class="val">DM</td>
</tr>
<tr>
<td>Market Cap</td>
<td id="marketCap" class="val">Non</td>
</tr>
<tr>
<td></td>
<td id="timestamp">As of 12:00 AM</td>
</tr>
<tr>
<td style="width:50%;"><input type="text" class="fullWidth fullHeight"></td>
<td style="width:50%"><input type="button" value="Get" class="fullWidth fullHeight"></td>
</tr>
</table>
</div>
My question is how can I make a button and textbox inside the table cell in the table above to get the full height of the row(I tried height:100%)?
Couple of things:
You have already defined 8px of padding under #dvStockCard table td{...} that's why you had default padding for all. Considering you need that padding I have overridden the td padding for last row.
Use border-collapse: collapse; for the row and padding & margin to 0 for td. Now you can use your desired height for that row.
#dvStockCard {
border-style: solid;
border-width: thin;
padding: 12px 5px 5px 5px;
}
.title {
font-size: small;
border-top: 2px solid #686868;
color: #383838;
padding: 8px calc(100% - 10ch) 0px 0px;
}
/*----table styles----*/
#dvStockCard table {
font-family: sans-serif;
font-weight: 600;
border-collapse: collapse;
width: 100%;
font-size: x-small;
}
#dvStockCard table tr {
border-bottom: 2px solid lightgray;
color: #707070;
}
#dvStockCard table td {
padding: 8px;
}
#dvStockCard table tr td:nth-child(2) {
text-align: right;
}
/*------values styles------*/
.val {
font-size: small;
color: black;
}
#lastPrice {
font-family: 'Palatino Linotype';
font-size: 160%;
color: black;
}
#change {
font-family: 'Palatino Linotype';
font-size: 160%;
color: green;
}
.halfWidth {
position: relative;
;
width: 50%;
}
/*-------helpers styles--------*/
.spaceTop-10 {
margin-top: 10px
}
.spaceBottom-10 {
margin-bottom: 10px
}
.trClass {
border-collapse: collapse;
}
.trClass td {
height: 40px;
padding: 0 !important;
/* need this because you already used 8px to the td*/
margin: 0 !important;
/* need this because you already used 8px to the td*/
}
.fullWidth {
width: 100%;
}
.fullHeight {
height: 100%;
}
<div id="dvStockCard">
<div class="title spaceBottom-10">My data cart</div>
<table>
<tr>
<td id="lastPrice">no price</td>
<td id="change">1234324t</td>
</tr>
<tr>
<td>Range</td>
<td id="range" class="val">No Rnge</td>
</tr>
<tr>
<td>Open</td>
<td id="open" class="val">555</td>
</tr>
<tr>
<td>Volume</td>
<td id="volume" class="val">DM</td>
</tr>
<tr>
<td>Market Cap</td>
<td id="marketCap" class="val">Non</td>
</tr>
<tr>
<td></td>
<td id="timestamp">As of 12:00 AM</td>
</tr>
<tr class="trClass">
<td style="width:50%;"><input type="text" class="fullWidth fullHeight"></td>
<td style="width:50%"><input type="button" value="Get" class="fullWidth fullHeight"></td>
</tr>
</table>
</div>
You could try wrapping it up in a container and later set it to 100% height. If not, you could try setting the height in px, you go trying different measurements until you see which one fills your desire. I hope I could help you
I am having issues with certain styles not showing correctly in browsers for tables that I created. Specifically the class I created .rowB background color not showing as well as the right side border that I created for class cellBrdrRght.
#charset "UTF-8";
/* CSS Document */
/* info charts */
td{
vertical-align: middle;
}
.chartHeader{
background-color: #115967!important;
color: #fff;
text-align: center;
font-weight: bold;
}
.rowA{
background-color: #d0d0d0!important;
color: #4b4b4b;
.rowB{
background-color: #666666!important;
color: #fff;
}
.cellBrdrRght {
border-style: solid!important;
border-width: 0px 1px 0px 0px!important;
border-color: white!important;
}
.cellnoBrd {
border-style: none;
}
.tableFooter{
font-size: 10px;
border-style: none;
background-color: #115967!important;
color: #fff;
text-align: left;
colspan: 3;
a:sideBar {
background-color: #115967!important;
padding: 25px 50px 75px 100px;
color: #fff;
}
<link href="http://benefitsatbenefitelect.com/new/wp-content/styles/other-styles.css" rel="stylesheet" type="text/css">
<div style="overflow-x: auto;">
<table>
<tbody>
<tr class="chartHeader">
<td class="cellBrdrRght">Plan Benefits</td>
<td class="cellnoBrd" colspan="2">Current Benefits</td>
</tr>
<tr class="rowA">
<td class="cellBrdrRght">Description</td>
<td class="cellBrdrRght">PPO</td>
<td class="cellnoBrd">HDHP</td>
</tr>
<tr class="rowB">
<td class="cellBrdrRght" style="text-align:left;"><b>Deductible</b> In/Out-of-Network & 2x Family</td>
<td class="cellBrdrRght">$1,250/$2,250**</td>
<td class="cellnoBrd">$3,000/$6,000**</td>
</tr>
<tr class="rowA">
<td class="cellBrdrRght" style="text-align:left;"><b>Coinsurance</b> In/Out-of-Network</td>
<td class="cellBrdrRght">Alaska Plan 20%/20%<br> Non-Alaska Plan 20%/40%</td>
<td class="cellnoBrd">Alaska Plan 20%/20%<br> Non-Alaska Plan 20%/40%</td>
</tr>
<tr class="rowB">
<td class="cellBrdrRght" style="text-align:left;"><b>Out-of-Pocket Maximum</b> In/Out-of-Network & 2x Family</td>
<td class="cellBrdrRght">$5,000/$10,000</td>
<td class="cellnoBrd">$5,000/$10,000</td>
</tr>
<tr class="rowA">
<td class="cellBrdrRght" style="text-align:left;"><b>Primary/Specialist Office</b></td>
<td class="cellBrdrRght">$30 PCP/$40 Specialist</td>
<td class="cellnoBrd">Alaska Plan*: PCP 20%/20% Specialist 20%/20%<br> Non-Alaska Plan*: PCP 20%/40% Specialist 20%/40%</td>
</tr>
<tr class="rowB">
<td class="cellBrdrRght" style="text-align:left;"><b>Retail Prescriptions</b>Generic/Preferred/Non-Preferred</td>
<td class="cellBrdrRght">$20/$45/$60</td>
<td class="cellnoBrd">20%*</td>
</tr>
<tr class="tableFooter">
<td colspan="3">*After Deductible is met **Individuals in Family Tier need only meet individual deductible vs. family deductible</td>
</tr>
</tbody>
</table>
<hr/>
</div>
web page:
http://benefitsatbenefitelect.com/new/index.php/portfolio-item/dark-places/
css file:
http://benefitsatbenefitelect.com/new/wp-content/styles/other-styles.css
#charset "UTF-8";
/* CSS Document */
/* info charts */
td{
vertical-align: middle;
}
.chartHeader{
background-color: #115967 !important;
color: #fff;
text-align: center;
font-weight: bold;
}
.rowA{
background-color: #d0d0d0 !important;
color: #4b4b4b;
}
.rowB{
background-color: #666666 !important;
color: #fff;
}
.cellBrdrRght {
border-style: solid !important;
border-width: 0px 1px 0px 0px !important;
border-color: white !important;
}
.cellnoBrd {
border-style: none;
}
.tableFooter{
font-size: 10px;
border-style: none;
background-color: #115967 !important;
color: #fff;
text-align: left;
colspan: 3;
}
a:sideBar {
background-color: #115967 !important;
padding: 25px 50px 75px 100px;
color: #fff;
}
Change this your .rowA & .tableFooter is not closed properly in {}...
You missed closing tags in .rowA:
.rowA{
background-color: #d0d0d0!important;
color: #4b4b4b;
}
and in .tableFooter:
.tableFooter{
font-size: 10px;
border-style: none;
background-color: #115967!important;
color: #fff;
text-align: left;
colspan: 3;
}
Try this and it should properly work
I am trying to create a hover element that displays a table of data.
I am having trouble making the hover element stack above the main table.
I have tried several things, including fixing the position and adjusting the z-index but everything seems to break the formatting and position of the hover element (i.e it needs to be positioned relative to the text that is hovered over and needs to adjust in width and height).
Example: https://jsfiddle.net/f1hLrwvf/
span.own3 {
background: #FFFFFF;
opacity: 1;
border: 1px solid #DCDCDC;
color: #000000;
font-size: 12px;
height: auto;
width: auto;
min-width: 300px;
letter-spacing: 1px;
line-height: 14px;
position: absolute;
text-align: justify;
top: 20px;
left: 0px;
display: none;
padding: 2px 5px;
font-family: "Helvetica Neue", Arial, sans-serif;
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1), 0 3px 10px 0 rgba(0, 0, 0, 0.09);
}
hover.own2 {
position: relative;
}
hover.own2:hover span {
display: block;
}
.table.hoverstatus>tbody>tr:first-child>th {
border: none;
}
<div style="padding:15px;">
<div class="shadow p-3 mb-5 bg-white rounded table-responsive" style="border: 1px solid #F0F0F0;font-family: 'Poppins', sans-serif;font-size:14px;">
<table id="example" class="table table-striped" width="100%">
<thead>
<tr>
<th>Feeling</th>
<th>Day</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Super
</td>
<td>1</td>
</tr>
<tr>
<td>
<hover class="own2">Great<span class="own3"><table class="table hoverstatus" id="innertable"><tr><th>Row1 Col1</th><th>Row1 Col2</th><th>Row1 Col3</th></tr><tr><td>Row2 Col1</td><td>Row2 Col2</td><td>Row2 Col3</td></tr></table></span></hover>
</td>
<td>2</td>
</tr>
</tbody>
</table>
</div>
</div>
Any guidance is greatly appreciated.
use position: absolute; instead position: relative;
Try code below:
span.own3 {
background: #FFFFFF;
opacity: 1;
border: 1px solid #DCDCDC;
color: #000000;
font-size: 12px;
height: auto;
width: auto;
min-width: 300px;
letter-spacing: 1px;
line-height: 14px;
position: absolute;
text-align: justify;
top: 20px;
left: 0px;
display: none;
padding: 2px 5px;
font-family: "Helvetica Neue", Arial, sans-serif;
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1), 0 3px 10px 0 rgba(0, 0, 0, 0.09);
}
hover.own2 {
position: absolute;
}
hover.own2:hover span {
display: block;
}
.table.hoverstatus>tbody>tr:first-child>th {
border: none;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<div style="padding:15px;">
<div class="shadow p-3 mb-5 bg-white rounded table-responsive" style="border: 1px solid #F0F0F0;font-family: 'Poppins', sans-serif;font-size:14px;">
<table id="example" class="table table-striped" width="100%">
<thead>
<tr>
<th>Feeling</th>
<th>Day</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Super
</td>
<td>1</td>
</tr>
<tr>
<td>
<hover class="own2">Great<span class="own3"><table class="table hoverstatus" id="innertable"><tr><th>Row1 Col1</th><th>Row1 Col2</th><th>Row1 Col3</th></tr><tr><td>Row2 Col1</td><td>Row2 Col2</td><td>Row2 Col3</td></tr></table></span></hover>
</td>
<td>2</td>
</tr>
</tbody>
</table>
</div>
</div>
You need to change some html markup as well as css
span.own3 {
background: #FFFFFF;
opacity: 1;
border: 1px solid #DCDCDC;
color: #000000;
font-size: 12px;
height: auto;
width: auto;
min-width: 300px;
letter-spacing: 1px;
line-height: 14px;
position: absolute;
text-align: justify;
top: 100%; // Changed to percentage instead of px
left: 0px;
display: none;
padding: 2px 5px;
font-family: "Helvetica Neue", Arial, sans-serif;
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1), 0 3px 10px 0 rgba(0, 0, 0, 0.09);
}
hover.own2 {
position: relative;
}
hover.own2:hover span {
display: block;
}
.table.hoverstatus>tbody>tr:first-child>th {
border: none;
}
.dd-label {
padding: 10px 0;
display: inline-block;
}
<div style="padding:15px;">
<div class="shadow p-3 mb-5 bg-white rounded table-responsive" style="border: 1px solid #F0F0F0;font-family: 'Poppins', sans-serif;font-size:14px;">
<table id="example" class="table table-striped" width="100%">
<thead>
<tr>
<th>Feeling</th>
<th>Day</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Super
</td>
<td>1</td>
</tr>
<tr>
<td>
<hover class="own2">
<!-- wrap this label in a span tag -->
<span class="dd-label">Great</span>
<!-- span tag ends -->
<span class="own3"><table class="table hoverstatus" id="innertable"><tr><th>Row1 Col1</th><th>Row1 Col2</th><th>Row1 Col3</th></tr><tr><td>Row2 Col1</td><td>Row2 Col2</td><td>Row2 Col3</td></tr></table></span></hover>
</td>
<td>2</td>
</tr>
</tbody>
</table>
</div>
</div>
Working fiddle here
Hope it will help you :)
I have the following table:
<table border="1" class="mmrTable" id="mmrdisplayTable">
<tbody><tr>
<td valign="top" style="width: 160px; font-weight: bold;" id="mmrdisplayTD">Running Projects:</td>
<td id="mmrdisplayTD">This month's running project</td>
</tr>
<tr>
<td valign="top" style="width: 160px; font-weight: bold;" id="mmrdisplayTD">Main Orders:</td>
<td id="mmrdisplayTD">This month's main orders</td>
</tr>
<tr>
<td valign="top" style="width: 160px; font-weight: bold;" id="mmrdisplayTD">Main Opportunities:</td>
<td id="mmrdisplayTD">This month's main opportunities</td>
</tr>
<tr>
<td valign="top" style="width: 160px; font-weight: bold;" id="mmrdisplayTD">Comments/Summary:</td>
<td id="mmrdisplayTD">no comments</td>
</tr>
</tbody></table>
As soon as I add a row above all rows the width of the first column of all the other rows changes from 160 to something else. Can someone tell me why? and help me reduce it to 160?
The code for the row that I add is:
<td colspan="2" class="headDisplay">Month: May|
Year: 2014| Submitted by: ibrahim nadir|
Submission Date: 2014-05-22| Submitting department: IT
</td>
The CSS is:
#mmrdisplayTable {
width: 100%;
}
.headDisplay{
background: none repeat scroll 0 0 #3C68AE;
border: 1px solid #DDDDDD;
color: #FFFFFF;
font-weight: bold;
height: 20px;
padding: 2px 10px;
}
#mmrdisplayTD{
border: 1px solid #ddd;
text-align: left;
padding:5px;
}
Any suggestions and help would be really appreciated!
It's a pretty easy solution.
Just add this to your css.
#mmrdisplayTable {
max-width: 320px;
}
#mmrdisplayTD {
min-width: 160px;
}
so your css looks like this:
#mmrdisplayTable {
width: 100%;
max-width: 320px;
}
headDisplay {
background: none repeat scroll 0 0 #3C68AE;
border: 1px solid #DDDDDD;
color: #FFFFFF;
font-weight: bold;
height: 20px;
padding: 2px 10px;
}
#mmrdisplayTD {
border: 1px solid #ddd;
text-align: left;
padding:5px;
min-width: 160px;
}
max-width in #mmrdisplayTable is just 160px * the amount of td's.
See the Fiddle i made.
I am working with a CSS table, and having an unexpected result - the table columns do not line up properly. This is what the table looks like
Here is the CSS
* {
/* old-style reset here :) */
border: 0px;
padding: 0px;
}
table {
border-collapse: separate;
border: 1px solid #9DABCE;
border-width: 0px 0px 1px 1px;
margin: 10px auto;
font-size: 20px;
width:90%;
}
td, th {
width: 41px;
height: 41px;
text-align: center;
font-size: 18px;
font-weight: bold;
vertical-align: middle;
background: url(../img/cells.png);
color: #444;
position: relative;
}
th {
font-weight: bold;
font-size: 14px;
}
td.today {
background-position: 81px 0px;
color: white;
}
And here is the table HTML
<table cellspacing="0">
<thead>
<th>Core Measure</th><th>National Average</th>
</thead>
<tbody>
<tr>
<td class="today">Discharge Instructions</td>
<td class="today">91%</td>
</tr>
<tr>
<td class="today">Measure LV Systolic Function</td>
<td class="today">98%</td>
</tr>
<tr>
<td class="today">ACE/ARB for LVSD</td>
<td class="today">95%</td>
</tr>
<tr>
<td class="today">Smoking Cessation</td>
<td class="today">99%</td>
</tr>
</tbody>
<tfoot>
<th>Core Measure</th><th>National Average</th>
</tfoot>
</table>
Assistance fixing this problem would be greatly appreciated. Thank you.
It is something to do with your sprite and the background-position values you set. I made a fiddle for you and it seems okay.