I have a table divided into a table head and table body. In order to make the table look a little nicer, the table head has a 2 part background image that gives it rounded corners. The table head does NOT have a border.
The table body does have a border. Therefore, it appears to stick out a little bit beyond the table head on the right and the left.
I want to make the table head (without a border) the same size as the table body (with a border). Any ideas as to how to accomplish this?
The HTML:
<table id="outerTable">
<!-- No border -->
<!-- Smaller than tbody on right and left -->
<thead>
<tr id="outerRow">
<th id="titleTh">Table Title</th>
</tr>
</thead>
<!-- Has border -->
<tbody id="outerBody">
</tbody>
</table>
The CSS:
#outerTable{
margin: 0px auto 0px auto;
font-size: 12px;
background-color: white;
border-collapse: collapse;
}
#titleRow{
background-image: url('/images/vinHead_r.png');
background-repeat: no-repeat;
background-position: right top;
margin-top: 0px;
}
#titleTh
{
font-size: 16px;
background-image: url('/images/vinHead_l.png');
background-repeat: no-repeat;
background-position: left top;
color: #EEEEEE;
padding:5px 5px 5px 20px;
text-align: center;
cursor: pointer;
margin-bottom: 0px;
margin-top: 0px;
}
#outerBody{
border: 2px solid #666666;
}
Assign a border to thead ( if you can ) that matches the main bg of your wrapper, most likely white?
tbody {
border: 2px solid transparent;
}
Edit: I forgot you could set a transparent border. If that works in IE, go ahead.
Related
I am working on my website and I have most of the design worked out, shown in the first image. I am trying to make the header row have no space (more accurately, make it look that way by having the image span across the entire row with no spaces.), but still have the elements themselves have space in between them.
Image showing a joined header, but separate body elements:
I am aware of the border-spacing css style, but it has to be applied to the table element, which means it will apply to headers and body elements. This with with a border-spacing set
Image showing what happens to the images when the border-spacing is set on the table:
I did attempt to find an answer before posting and usually I find the answer fairly quickly, but this one seems to be a rare request. I prefer to avoid hacks if possible, but I will use them if its the only way. Also, if possible, I'd like it to be cross-browser capable. (changes to the solution are ok of course, just something that I can make work will all of them.)
I guess code is helpful to show. Here is the html:
<table id="users">
<caption>Point Totals</caption>
<thead>
<tr>
<th>Name</th>
<th>Points</th>
</tr>
</thead>
<tbody>
<tr>
<td>Xogue</td>
<td>64433</td>
</tr>
<tr>
<td>Jesse</td>
<td>104040</td>
</tr>
<tr>
<td>Nanokarp</td>
<td>280</td>
</tr>
<tr>
<td>Brandon</td>
<td>70</td>
</tr>
</tbody>
</body>
and the css:
#users {
border-spacing: 6px;
width: 444px;
float: left;
margin: 20px 90px;
}
#users caption {
background-image: url("_images/points_label.png");
background-size: 200px 35px;
background-position: center center;
background-repeat: no-repeat;
height: 31px;
font-size: 20px;
padding-top: 8px;
}
#users thead {
background-image: url("_images/point_tr_head_back.png");
background-repeat: no-repeat;
}
#users th {
text-align: left;
padding: 9px 30px;
font-size: 20px;
}
#users td {
border: 2px solid #226fdb;
border-radius: 25px;
font-size: 20px;
padding: 18px 5px 2px 25px;
line-height: 15px;
background: #FFFFFFEE;
}
Note: Some of the styles used are likely unnecessary. I've been toying with it for a while and haven't cleaned it up yet.
SOLVED: further down if you would like to see the example. but put simply, wrap the content in a different element (like a span) and move all styles to the new element.
I think you could get there fairly easily with some margins and padding if you can wrap the cell contents in a span (or whatever).
table {
text-align: left;
border-spacing: 0;
}
thead tr {
box-shadow: inset 0 0 12px rgba(0,0,0,0.5);
border-radius: 24px;
}
th {
padding: 6px 1em;
}
th:first-child {
border-radius: 24px 0 0 24px;
}
th:last-child {
border-radius: 0 24px 24px 0;
}
tbody td > span {
display: block;
border: 2px solid blue;
background: aliceblue;
border-radius: 24px;
margin: 6px 6px 0 0;
padding: 0.25em 1em;
}
<table>
<thead>
<tr>
<th>Name</th>
<th>Points</th>
</thead>
<tbody>
<tr>
<td><span>Xogue</span></td>
<td><span>262677</span></td>
</tr>
<tr>
<td><span>Jesse</span></td>
<td><span>17632</span></td>
</tr>
<tr>
<td><span>Nanokarp</span></td>
<td><span>12344</span></td>
</tr>
</tbody>
</table>
One option is to add padding to your CSS for td only and keep rest of the attributes same among td and th as below, also if you can share the used code snippet someone can help better:
td {
padding: 5px;
}
Both the gray background row and the white background row below are two separate tables. The white background table is the 'overflow-y' property set to scrollable is the number of elements within it exceeds 100px.
CSS for tables:
table {
border-collapse: collapse;
width: 100%;
}
HTML for gray table:
<div style="padding-bottom: 2px">
<table>
<thead>
<tr>
<th>Start Time</th>
<th>End Time</th>
<th>User1</th>
<th>User2</th>
<th></th>
</tr>
</thead>
</table>
</div>
CSS for gray table:
th {
background-color: #E0E0E0;
font-size: 20px;
font-weight: bold;
padding: 8px 0px 8px 0px;
text-align: left;
vertical-align: bottom;
width: 20%;
}
HTML for white table:
<div style="height:95%;overflow:auto">
<table id="modalTable" style="table-layout: fixed; width: 100%" >
<tbody>
<tr ng-repeat-start="value in MaintenanceModeEvents" class="event">
<td>{{'Start Time: MM-dd-yyyy HH:mm:ss'}}</td>
<td>{{'End Time: MM-dd-yyyy HH:mm:ss'}}</td>
<td>{{'User 1'}}</td>
<td>{{'User 2'}}</td>
<td><button type="button"</td>
</tr>
</tbody>
</table>
</div>
CSS for white table:
tr.event {
border-top: 1px solid #808080;
/*border-bottom: 1px solid #808080;*/
font-size: 14px;
padding: 8px 16px;
text-align: left;
}
The header of the gray background table is evenly spaced at 20% (there is a th with nothing in it above view comments) when the white background table's contents doesn't exceed 100px. The issue that I am running into is when the white background table's contents exceeds 100px, the scroll bar's width takes up space in the white background table and the headers from the gray background table no longer align with the white background table as seen above. How can I handle this issue? Any help would be great!
Please take a look at this fiddle. How can I make the images in th align with each other? Some titles below the images appear to be too long and pushing the images up a bit. I have tried removing padding: 20px; and given it a fixed height but failed. Any suggestions?
HTML
<table id="comparetable" class="blueshine">
<tr>
<td class="blank"></td>
<th><img class="thumbnail" src="image.jpg"><p>jhjhjhik iukiuk iukiu</th>
<th><img class="thumbnail" src="image.jpg"><p>jhjhjhik</th>
<th><img class="thumbnail" src="image.jpg"><p>jhj isdoi idi93</th>
</tr>
<tr>
<td class="rowTitle">Price</td> <td>$4.5</td>
<td>$1.5</td>
<td>$3.5</td>
<td>$1.5</td>
</tr>
.....
</table>
CSS
/* START COMPARISON TABLE STYLES */
#comparetable {width: 100%; table-layout: fixed; text-align: center; margin: 4em 0; border-collapse: collapse; }
#comparetable tr {background: transparent!important;}
#comparetable td,
#comparetable th {padding: 20px; text-align: center;}
#comparetable td.rowTitle {text-align: left;}
.blank {background: none!important; border: none!important;}
.blueshine th {background-color: #b8cee2; font-size: 22px; color: #0c3053; text-align: center; font-weight: 600; text-shadow: 0 1px 0 #e0ecf7; border: 1px solid #9fb6c8; } color: #222;
font-size: 2em;
}
.thumbnail {width:80px;height:60px;}
th { vertical-align:top }
Should do the trick: JSFiddle Demo
best it's to add a second row of th: in first one you put images (with css rule vertical-align: top) and in second one you'll put titles with same css rule.
This would be best solution when you have images with different heights and/or titles with differents heights.
More. if you have no images, titles will stay at same line.
I have a table which has two rows and three columns. The first row serves the purpose of body and the second row serves the purpose of footer.
I want to design the footer using CSS, so that the look and feel is better. I can add the image, but there is gap between between each image so it has not come out well.
The row tr has three columns, and each td has one image.
Below is the HTML code.
<tr>
<td class="FooterLeftBG"> //left css class
</td>
<td style="width: 85%;" class="FooterBG"> //middle css class
<table style="width: 85%">
<tr>
<td align="left">
some text
</td>
<td style="padding-top: 1px">
some text</td>
</tr>
</table>
</td>
<td class="FooterRightBG"></td>//right css class
</tr>
Here is the CSS code:
td.FooterLeftBG // CSS class for left td, used to make left hand side curve footer
{
background: url('footer-leftbg.png') bottom left;
height:35px;
width:12px;
padding:0px;
float:right;
}
td.FooterRightBG // CSS class for right td, used to make right hand side curve footer
{
background: url('footer-right-bg.png') bottom right;
height:35px;
padding:0px;
width:12px;
float:left;
}
td.FooterBG // CSS class for td holding the footer contents
{
background:url('footer-middle-bg.png');
background-repeat:repeat-x;
border-collapse:collapse;
height:35px;
width:5px;
}
Please help. I have been trying for 1 week :( I have tried through Google also.
Expected format:
http://i.stack.imgur.com/c7ULg.png
http://i.stack.imgur.com/2J4zW.png
You can wrap your table inside a Div, and apply the below CSS class to it. The sample has all four curved borders, you can modify the radius values as per your requirement:
.container {
background-attachment: scroll;
background-clip: border-box;
background-color: #FFFFFF;
background-image: none;
background-origin: padding-box;
background-position: 0 0;
background-repeat: repeat;
background-size: auto auto;
border-bottom-left-radius: 7px;
border-bottom-right-radius: 7px;
border-top-left-radius: 7px;
border-top-right-radius: 7px;
box-shadow: 0 0 10px #909090;
cursor: default;
display: none;
left: 12px;
padding-bottom: 10px;
padding-left: 10px;
padding-right: 10px;
padding-top: 10px;
position: relative;
text-align: left;
z-index: 100;
}
If you want to stick with a table for your layout, you could try applying the following CSS to the <table> tag:
border-collapse: collapse;
That might get rid of the space between the footer images.
Try adding cellspacing='0' to your table tag in the HTML
I'm getting crazy with getting my table look right on different browsers, just when I think I got in one it changes in the other. IE7/8 and Firefox are my target browsers.
Could someone please have a look at the code I just can't figure out what's the problem.
Table is generated by Javascript, I need it have fixed width of 220px, the main problem is tfoot where I have 3 tds for which I'm having problems controlling width.
Here is the relevant portion of the code:
<table class="favouritelinks" cellspacing="0" cellpadding="0" width="220" >
<thead>
<tr><td colspan="3">Your Favourite Links</td></tr>
</thead>
<tbody id="tulemused" ></tbody>
<tr>
<td width="50">Name</td><td><input type="text" id="key" name="key" value="" /></td>
<td rowspan="2"><div class="addimg"></div></td>
</tr>
<tr>
<td width="50">URL</td><td><input type="text" id="val" name="val" value="" /></td>
</tr>
</table>
and css:
.favouritelinks td{
height: 20px;
padding: 3px;
border-bottom: 1px solid white;
word-break: break-all;
}
.favouritelinks td a{
color: white;
text-decoration: none;
}
thead{
background: url(img/title5.png) no-repeat;
color: #444;
font: bold 16px Helvetica;
text-shadow: 0 1px 0 #FFF;
text-align: center;
width: 220px;
height: 36px;
}
thead tr {
height: 36px;
}
.container{
width: 220px;
margin-top: 105px;
margin-left: 10px;
}
.delimg {
background: url(img/details_close.png) no-repeat;
width: 20px;
height: 20px;
float: right;
}
.addimg {
background: url(img/details_open.png) no-repeat;
width: 20px;
height: 20px;
float: right;
}
.urls {
display: none;
}
What am I doing wrong?
Picture http://imageshack.us/photo/my-images/38/56751263.jpg/
Try this in your CSS:
table {
table-layout: fixed;
}
Remove the padding:3px from .favouritelinks td in CSS and all will be OK.
OR BETTER WAY
set td width in CSS not in HTML
I had the same problem with layout good in IE9+, but bad in IE 7/8. I found out "colspan" was the problem when this column is wider then the sum of other matching columns not colspan on other rows. I was specifiying fixed width on all columns except the one I want to be adjusted with the remaining width. But that didn't work on IE 7/8. So I end up splitting rows on different "table" to workaround that layout problem.