I have a selectable table (jQuery UI selectable). How do i "access" the edge (top, left, right, bottom) width css, or do I have to use javascript?
Update: with "accessing the edge" I mean for example create a border around a selected area in a table (select td elements, first .ui-selected in tr, last .ui-selected in tr, first tr containing .ui-selected, last tr containing .ui-selected).
<table class="ui-selectable">
<tr>
<td class="ui-selectee"></td>
<td class="ui-selectee"></td>
<td class="ui-selectee"></td>
<td class="ui-selectee"></td>
</tr>
<tr>
<td class="ui-selectee"></td>
<td class="ui-selectee ui-selected"></td>
<td class="ui-selectee ui-selected"></td>
<td class="ui-selectee"></td>
</tr>
<tr>
<td class="ui-selectee"></td>
<td class="ui-selectee ui-selected"></td>
<td class="ui-selectee ui-selected"></td>
<td class="ui-selectee"></td>
</tr>
<tr>
<td class="ui-selectee"></td>
<td class="ui-selectee"></td>
<td class="ui-selectee"></td>
<td class="ui-selectee"></td>
</tr>
</table>
ex: the left edge
.ui-selected {
border-left: 1px solid #00F;
}
.ui-selected ~ .ui-selected {
border-left: none;
}
Left:
td:first-child
Right:
td:last-child
Top:
tr:first-child td
Bottom:
tr:last-child td
Edit: with your updates, I can now state that there is no way to do it in CSS3. But CSS4's :nth-match and :nth-last-match (not implemented anywhere at the time of writing, and the spec is only a working draft) will be able to do it.
Related
I have a table with a thead and a tbody. I add a border-bottom to the thead and a background-color on the td in the tbody there seems to be some bleed in. This only happends in firefox :
Requirements :
It needs to look exactly the same in chrome firefox
You can't use empty cells
border-collapse cannot be changed
table {
border-collapse:collapse;
font-size:20px;
}
thead {
border-bottom:20px solid green;
}
thead td {
border-right :2px solid blue;
}
tbody td {
background-color:red;
}
<table>
<thead>
<tr>
<td rowspan="2">lorem</td>
<td>lorem</td>
<td>lorem</td>
<td>lorem</td>
</tr>
<tr>
<td>lorem</td>
<td>lorem</td>
<td>lorem</td>
</tr>
</thead>
<tbody>
<tr>
<td colspan="4">lorem</td>
</tr>
</tbody>
</table>
The bug seems to be related by the fact that the td's in the first tr in the tbody, don't share the same borders as the td's in the last tr in the thead. This is happening because of the colspan="4".
A way to circumvent this issue is to put in a tr at the top of the tbody, that no-one can see ( because it has no height ).
table {
border-collapse:collapse;
font-size:20px;
}
thead {
border-bottom:20px solid green;
}
thead td {
border-right :2px solid blue;
}
tbody td {
background-color:red;
}
tbody>tr:first-child{
height: 0px;
}
<table>
<thead>
<tr>
<td rowspan="2">lorem</td>
<td>lorem</td>
<td>lorem</td>
<td>lorem</td>
</tr>
<tr>
<td>lorem</td>
<td>lorem</td>
<td>lorem</td>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="4">lorem</td>
</tr>
</tbody>
</table>
Or maybe.. this alternative where I removed the bottom-border, but replaced it by a green row.
table {
border-collapse:collapse;
font-size:20px;
}
thead td {
border-right :2px solid blue;
}
tbody td {
background-color:red;
}
th:last-child{
height: 20px;
background-color:green;
}
<table>
<thead>
<tr>
<td rowspan="2">lorem</td>
<td>lorem</td>
<td>lorem</td>
<td>lorem</td>
</tr>
<tr>
<td>lorem</td>
<td>lorem</td>
<td>lorem</td>
</tr>
<tr>
<th colspan="4"></th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="4">lorem</td>
</tr>
</tbody>
</table>
PS: You should use th instead of td in headers
I have this table inside another table, i want to remove the border from the cells of child table(around A and B).
Below is the source code for this.
<style>
.withBorders tr td{
border: 1px solid black !important ;
}
.withBorders table.withoutBorders tr td {
border:0px
}
</style>
<table class="withBorders">
<tr>
<td>
<table class="withoutBorders">
<tbody>
<tr>
<td>A</td>
<td>B</td>
</tr>
</tbody>
</table>
</td>
<td>C</td>
</tr>
<tr>
<td>D</td>
<td>E</td>
</tr>
</table>
The problem is this isn't working, i have tried many changes with child table's css selector but i am unable to override parent table css property.
Could someone please advice on this?
Note: I can not make any changes to the parent table css selector.
.withBorders tr td{
border: 1px solid black;
}
.withBorders tr td table tr td {
border:none;
}
<table class="withBorders">
<tr>
<td>
<table class="withoutBorders">
<tbody>
<tr>
<td>A</td>
<td>B</td>
</tr>
</tbody>
</table>
</td>
<td>C</td>
</tr>
<tr>
<td>D</td>
<td>E</td>
</tr>
</table>
repeat what you typed, don't change your typing like this
.withBorders table.withoutBorders tr td {
border:0px
}
avaoid !important in your css. it's not good.
You can easily use the code like this:
.withBorders tr td{
border: 1px solid black;
}
.withBorders table.withoutBorders tr td {
border:0px
}
<table class="withBorders">
<tr>
<td>
<table class="withoutBorders">
<tbody>
<tr>
<td>A</td>
<td>B</td>
</tr>
</tbody>
</table>
</td>
<td>C</td>
</tr>
<tr>
<td>D</td>
<td>E</td>
</tr>
</table>
"!important" means that if it is some choice between 2 styles, it will be choosen the style with higher priority. (the style which contains "!important")
Hello I have these following tables for which I want same vertical line. please check my code here link I have two vertical tables, I want same vertical line of alignment for both the tables so that The line between two tables appears same though the tables are different.
Here is what I want
Here is what I am getting if I add text to th .
please tell me how can I make it better.
table,
th,
td {
border: 1px solid black;
}
<table style="width:100%" cellpadding="10px" cellspacing="1px" padding="20px">
<tr>
<th>Month</th>
<td>Savings</td>
</tr>
<tr>
<th>January</th>
<td>$100</td>
</tr>
<tr>
<th>February</th>
<td>$80</td>
</tr>
</table>
<table style="width:100%">
<tr>
<th>Monthasnsandf</th>
<td>Savings</td>
</tr>
<tr>
<th>Januarydfsadfas</th>
<td>$100</td>
</tr>
<tr>
<th>Februarydfsadfsafa</th>
<td>$80</td>
</tr>
</table>
You could simply specify the width for the th and td elements, say 50%.
table, th, td {
border: 1px solid black;
}
table th, table td {
width: 50%;
}
table th {
text-align: left;
}
<table style="width:100%" cellpadding="10px" cellspacing="1px" padding="20px">
<tr>
<th>Month</th>
<td>Savings</td>
</tr>
<tr>
<th>January</th>
<td >$100</td>
</tr>
<tr>
<th>February</th>
<td >$80</td>
</tr>
</table>
<table style="width:100%" cellpadding="10px" cellspacing="1px" padding="20px">
<tr>
<th>Monthasnsandf</th>
<td>Savings</td>
</tr>
<tr>
<th>Januarydfsadfas</th>
<td >$100</td>
</tr>
<tr>
<th>Februarydfsadfsafa</th>
<td >$80</td>
</tr>
</table>
what I did is put the two tables in another table which has 2 rows to perfectly match vertical alignment
table, th, td {
border: 1px solid black;
}
table th, table td {
width: 50%;
}
<table>
<tr>
<td>
<table style="width:100%">
<tr>
<th>Month</th>
<td>Savings</td>
</tr>
<tr>
<th>January</th>
<td >$100</td>
</tr>
<tr>
<th>February</th>
<td >$80</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table style="width:100%">
<tr>
<th>Monthasnsandf</th>
<td>Savings</td>
</tr>
<tr>
<th>Januarydfsadfas</th>
<td >$100</td>
</tr>
<tr>
<th>Februarydfsadfsafa</th>
<td >$80</td>
</tr>
</table>
</td>
</tr>
</table>
I assume this is what you expect!
I'd tried to make a line as an image below which runs through the table but it didn't work.
I would like to
make a line like the image.
set a bullet for each <td> in the 2nd table
HTML:
<table>
<tr>
<table class="a">
<tr>
<td style="width: 300px">Shuttle Bus Schedule | Make an appointment</td>
<td style="width: 220px">My Request</td>
</tr>
</table>
</tr>
<tr>
<table>
<tr>
<td style="width: 300px">Need Approval by Manager</td>
<td style="width: 220px">Need Approval by Coordinator</td>
</tr>
<tr>
<td>Approved by Manager</td>
<td>Approved by Coordinator</td>
</tr>
<tr>
<td>Rejected by Manager</td>
<td>Rejected by Coordinator</td>
</tr>
</table>
</tr>
</table>
CSS:
.a {
border-bottom: 1px solid #c4c4c4;
}
Structure your table properly with table headings (<th>) instead of nested tables:
<table>
<tr>
<th style="width: 300px">Shuttle Bus Schedule | Make an appointment</th>
<th style="width: 220px">My Request</th>
</tr>
<tr>
<td>Need Approval by Manager</td>
<td>Need Approval by Coordinator</td>
</tr>
<tr>
<td>Approved by Manager</td>
<td>Approved by Coordinator</td>
</tr>
<tr>
<td>Rejected by Manager</td>
<td>Rejected by Coordinator</td>
</tr>
</table>
CSS:
th {border-bottom:1px solid #c4c4c4};
td:before {content:"\2022";}
You can see this here on jsfiddle.
The table structure is not really in good format. However to keep the same table structure you can achieve the results. See the DEMO.
Here is the CSS need to used.
.a {
border-top: 1px solid transparent;
}
table{border: 1px solid transparent;
border-collapse:collapse;}
table td{ padding:5px; margin:5px;}
table+table td:last-child{border-left:
1px solid #c4c4c4;}
table+table td:last-child:before{content:"\2022"}
table+table{border-top: 1px solid #c4c4c4; }
table.a td:last-child:before{content:" "}
The working version of the html table generated markup with css is here:
http://jsfiddle.net/nexU/JkUCQ/1/
As you can see all I need is to set these align and width styles for those 3 specific TD tags on a external css and override the ones that are automatically generated by asp control.
Thanks in advance for your help.
/*
I want 1st pagerRow TD to have width 10%
I want 2nd pagerRow TD to have width 80%
I want 3rd pagerRow TD to have width 10%
*/
/------------style.css------------/
.pagerRow
{
background: #3D6AA2;
font-weight: normal;
color: #fff;
text-align: left;
height: 30px;
}
.pagerRow td
{
border: solid 1px red;
}
/------------ part of html generated by control------------/
<table id="mainContacts" class="contactsBase" cellspacing="0" border="1" style="width: 100%;">
<tbody>
<tr class="header_row">
</tr>
<tr class="odd">
</tr>
<tr class="even">
</tr>
<tr class="odd">
</tr>
<tr class="even">
</tr>
<tr class="odd">
</tr>
<tr class="even">
</tr>
<tr class="odd">
</tr>
<tr class="even">
</tr>
<tr class="odd">
</tr>
<tr class="even">
</tr>
<tr class="odd">
</tr>
<tr class="pagerRow" align="center">
<td colspan="5">
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tbody>
<tr>
<td align="left" width="25%"> <!--How to set these align and width styles on external css and override these ones that are automatically generated by asp control?-->
</td>
<td align="center" width="50%"> <!--How to set these align and width styles on external css and override these ones that are automatically generated by asp control?-->
<p> 1,2,3,4,5 </p>
</td>
<td align="right" width="25%"> <!--How to set these align and width styles on external css and override these ones that are automatically generated by asp control?-->
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
Working fiddle: http://jsfiddle.net/JkUCQ/4/
(updated based on your new input)
Add this to your CSS:
.pagerRow tr td:nth-child(1) {
width:10% !important;
}
.pagerRow tr td:nth-child(2) {
width:80% !important;
}
.pagerRow tr td:nth-child(3) {
width:10% !important;
}