I have a simple table:
<table class="caspGrid">
<thead></thead>
<tbody>
<tr class="caspRow">
<td class="caspColEntity">
<input type="checkbox"/>
<span>Favorites</span>
<p>(<span>2</span>)</p>
</td>
<td class="caspColSummary">
<p>FY13 SPM Mobility Strategy</p>
<p>FY13 SPM Mobility Strategy</p>
<p>FY13 SPM Mobility Strategy</p>
</td>
<td class="caspColTeam">
<p>Tim Smith</p>
<p>Tim Smith</p>
<p>Tim Smith</p>
</td>
</tr>
</tbody>
</table>
I'd like the table to span the entire page height but I want each <tr> to wrap around the content and the last <tr> to span the rest of the way, how can I do that?
HERE IS A FIDDLE
You can use last-of-type CSS3 pseudo-class:
tr:last-of-type {
height: 100%;
}
this will target only the last tr.
Demo: http://jsfiddle.net/5L7fb/
If you have multiple tables in one page, then you should use descendant or child selectors:
/* Descendant */
table tr:last-of-type {
height: 100%;
}
/* Child */
table > tr:last-of-type {
height: 100%;
}
Related
I have a table and in my td, I will have div. I need know how let user see different color when hovering at specific div
My code
<div className="table-responsive">
<table className="table table-responsive table-hover table-condensed returnSpreadIndex">
<thead>
<tr>
<th>Period/Range</th>
<th>n30</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="hover1"> // LET SAY USER HOVER THIS DIV, WILL SHOW YELLOW COLOR
Apple1
</div>
<div class="hover2"> // IF USER HOVER THIS DIV, WILL SHOW ORANGE COLOR
pineApple1
</div>
</td>
<td>testing purpose</td>
</tr>
<tr>
<td>test</td>
<td>
<div>
Apple2
</div>
<div>
pineApple2
</div>
</td>
</tr>
</tbody>
</table>
</div>
after I lookup solution for this , finally can come out with this code but it is not working either
div.table-responsive table.returnSpreadIndex tbody > tr > td>div:hover .hover1 {
background-color: yellow;
}
div.table-responsive table.returnSpreadIndex tbody > tr > td>div:hover .hover2 {
background-color: orange;
}
Thank you,
.table-responsive table .hover1:hover {
background-color: yellow;
}
.table-responsive table .hover2:hover {
background-color: orange;
}
<div class="table-responsive">
<table class="table table-responsive table-hover table-condensed returnSpreadIndex">
<thead>
<tr>
<th>Period/Range</th>
<th>n30</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="hover1">
Apple1
</div>
<div class="hover2">
pineApple1
</div>
</td>
<td>testing purpose</td>
</tr>
<tr>
<td>test</td>
<td>
<div>
Apple2
</div>
<div>
pineApple2
</div>
</td>
</tr>
</tbody>
</table>
</div>
This should work perfectly for you,
PS: pay attention to your attribute if you are not using this code inside a react app because ClassName is specific attribute for react
.hover1:hover { background-color: yellow} .hover2:hover {background-color: orange}
As mentioned by #OthManE01,
first warning is for the use of the attribute ClassName, that's specific for react, but not interpreted by HTML instead.
Second mistake is in the css selector. Going up the selection in your code you're gonna make the CSS-rule for an element with class .hover1 (or .hover2)
-direct child of a div:hover
-direct child of td
-direct child of tr
-direct child of tbody of all table with .returnSpreadIndex class, an so on...
Instead you wanna select div.hover1:hover and div.hover2:hover.
So the right CSS-rule could be:
div.table-responsive table.returnSpreadIndex tbody > tr > td>div.hover1:hover {
background-color: yellow;
}
div.table-responsive table.returnSpreadIndex tbody > tr > td>div.hover2:hover {
background-color: orange;
}
I am trying to make the following working the way I want it to. I want to have an Input element changing its width to the provided cell's width. Here is code:
<table style="margin-top:10px;width:80.5%;font-size:14px">
<tr>
<td style="text-align:left;width:5%">
<span translate>CaseNumber</span>:
</td>
<td style="text-align:left;width:5%">
<span>
<input easyui-textboxreadonly readonly ng-model="caseid" style="width:80px;height:32px;background-color:#72A4D2"/>
</span>
</td>
<td style="text-align:left;width:2%">
<span translate>Title</span>:
</td>
<td style="width:88%">
<div style="width:100%">
<input easyui-textbox data-options="required:true" ng-model="title" style="height:32px;"/>
</div>
</td>
</tr>
</table>
I want the input in the last cell to take all the width of the cell it's in.
Unless I provide a width of the input it's not happening.
Put width: 100% on the input element itself, not on a div surrounding it (you can get rid of that div altogether in fact).
Demo: http://jsfiddle.net/1qda1jpx/2/
table {
border: 1px solid blue;
}
td {
border: 1px solid lightgray;
}
input {
width: 100%;
}
<table style="margin-top:10px;width:80.5%;font-size:14px">
<tr>
<td style="text-align:left;width:5%">
<span translate>CaseNumber</span>:
</td>
<td style="text-align:left;width:5%">
<span>
<input easyui-textboxreadonly readonly ng-model="caseid" style="width:80px;height:32px;background-color:#72A4D2"/>
</span>
</td>
<td style="text-align:left;width:2%">
<span translate>Title</span>:
</td>
<td style="width:88%">
<input easyui-textbox data-options="required:true" ng-model="title" style="height:32px;"/>
</td>
</tr>
</table>
You need to set width: 100% for that input element. Otherwise it wont happen.
I'm having a bit of a problem putting together a HTML email which will render properly in outlook, i had initially got everything working fine through the use of list items and the list-style-image Property, but that isn't supported in outlook.
Basically, i have a table with 2 rows in it, the left hand side one has an 11pixel image being using as a custom bullet point, and on the right hand side is some text.
My problem is no matter what i do i cannot get the column on the left to maintain an 11 pixel width, the columns ALWAYS split equally down the middle of the table. Help please?
HTML
<table>
<tr>
<td>
<img src="Small Image" />
</td>
</tr>
<tr>
<td class="red">
<h4>
TEXT
</h4>
</td>
</tr>
<tr>
<td class="webinar">
<table>
<tr>
<td class="left">
<img src="/Bullet.png" />
</td>
<td class="right">
<p>
TEXT
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
CSS
td.webinar .left {
width:11px;
vertical-align:top;
padding:0px
margin:0px
}
td.webinar .right {
width:144px;
vertical-align:top;
padding:0px
margin:0px
}
td.webinar {
background-color:#ccc6d2;
border:1px solid #313131;
padding-top:8px;
padding-bottom:10px;
}
you want to use css styles in emails? then you are going to have a bad time in most clients..
try to:
<table>
<tr>
<td width="144px">
<img src="Small Image" />
</td>
</tr>
</table>
in email templates you should always apply inline styling as "oldschool" as possible!
I have created a table http://jsfiddle.net/vR5B8/.
table id="resultDetails" class="table-striped" border=1 width="99%" nowrap=0; cellspacing=0; cellpadding=3><tbody>
<th colspan="2"><Big>Result Details</Big></th>
<tr data-depth=0 class="collapse" height=1px >
<td width="4%">P</td>
<td width="80%">Modules
<div class="content">
<p>Abc</p>
</div>
</td>
</tr>
<tr data-depth=0 class="collapse" height=1px >
<td width="4%">P</td>
<td width="80%">Modules 1</td>
</tr>
<tr data-depth=0 class="collapse" height=1px >
<td width="4%">P</td>
<td width="80%">Modules 2</td>
</tr>
</tbody>
Some of the rows contain additional information which is hidden. If the row contains hidden information, then the height of row is increasing compare to the row which does not contain the hidden information. How to set the common height for all rows.
Any thoughts ?
Use display: none instead of visibility hidden demo
tr {
height: 50px;
}
for example :) or
tr {
height: auto;
}
depends of what you need :)
The table row height will increase dynamically in height if more information is added, but to hide an element, use display: none and to give a height to a row, use line-height: /* size */;
.content {
display:none;
}
tr {
min-height: 20px;
line-height: 20px;
}
Here's the jsFiddle
How can entire table cell be hyperlinked in html without javascript or jquery?
I tried to put href in td tag itself but its not working at least in chrome 18
<td href='http://www.m-w.com/dictionary/' style="cursor:pointer">
Try this:
HTML:
<table width="200" border="1" class="table">
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
CSS:
.table a
{
display:block;
text-decoration:none;
}
I hope it will work fine.
Try this way:
<td> </td>
Easy with onclick-function and a javascript link:
<td onclick="location.href='yourpage.html'">go to yourpage</td>
Why not combine the onclick method with the <a> element inside the <td> for backup for non-JS? Seems to work great.
<td onclick="location.href='yourpage.html'">Link</td>
Here is my solution:
<td>
<div class="item-container">
<img class="icon" src="/iconURL" />
<p class="name">
SomeText
</p>
</div>
</td>
(LESS)
td {
padding: 1%;
vertical-align: bottom;
position:relative;
a {
height: 100%;
display: block;
position: absolute;
top:0;
bottom:0;
right:0;
left:0;
}
.item-container {
/*...*/
}
}
Like this you can still benefit from some table cell properties like vertical-align.(Tested on Chrome)
Problems:
(User: Kamal) It's a good way, but you forgot the vertical align problem! using this way, we can't put the link exactly at the center of the TD element! even with vertical-align:middle;
(User: Christ) Your answer is the best answer, because there is no any align problem and also today JavaScript is necessary for every one... it's in every where even in an old smart phone... and it's enable by default...
My Suggestion to complete answer of (User: Christ):
HTML:
<td style="cursor:pointer" onclick="location.href='mylink.html'"><a class="LN1 LN2 LN3 LN4 LN5" href="mylink.html" target="_top">link</a></td>
CSS:
a.LN1 {
font-style:normal;
font-weight:bold;
font-size:1.0em;
}
a.LN2:link {
color:#A4DCF5;
text-decoration:none;
}
a.LN3:visited {
color:#A4DCF5;
text-decoration:none;
}
a.LN4:hover {
color:#A4DCF5;
text-decoration:none;
}
a.LN5:active {
color:#A4DCF5;
text-decoration:none;
}
you can give an <a> tag the visual behavior of a table cell:
HTML:
<table>
<tr>
Cell 1
<td>Cell 2</td>
</tr>
</table>
CSS:
tr > a {
display: table-cell;
}
I have seen this before when people are trying to build a calendar. You want the cell linked but do not want to mess with anything else inside of it, try this and it might solve your problem.
<tr>
<td onClick="location.href='http://www.stackoverflow.com';">
Cell content goes here
</td>
</tr>
Not exactly making the cell a link, but the table itself. I use this as a button in e-mails, giving me div-like controls.
<a href="https://www.foo.bar" target="_blank" style="color: white; font-weight: bolder; text-decoration: none;">
<table style="margin-left: auto; margin-right: auto;" align="center">
<tr>
<td style="padding: 20px; height: 60px;" bgcolor="#00b389">Go to Foo Bar</td>
</tr>
</table>
</a>
If you want use this way in php Do the following
<?php
echo ("
<script type = 'text/javascript'>
function href() {
location.href='http://localhost/dept';
}
</script>
<tr onclick='href()'>
<td>$id</td>
<td>$deptValue</td>
<td> $month </td>
<td>100%</td>
</tr>
");
?>