So I've been trying to figure out how to code exactly the same table as it is shown in this picture:
But with no results. I've no idea how to divide it with different colours so the green overlaps others and keeps the words in each grid.
I'd be very thankful if someone helped me to gave me some ideas please.
Here is a WORKING JSFIDDLE for you.
table{
border-collapse: collapse;
font-size: 24px;
}
table tr td{
border-top: 5px solid #9F2C2F;
border-right: 5px solid #057C08;
}
table tr th:first-child{
border-top: 5px solid yellow;
border-right: 5px solid #057C08;
}
table tr td:last-child{
border-right: none;
}
Another working css could be:
http://jsfiddle.net/wpwu5mfs/1
td, tr, table{
border-collapse: collapse;
}
td{
border-top: solid 4px red;
}
td:first-child{
border-top: solid 4px yellow;
}
td:not(:first-child){
border-left: solid 4px green;
}
<style type="text/css">
table
{
border-collapse: collapse;
}
table tr td:last-child
{
border-right: 0px;
}
.first
{
border-top:3px solid yellow;
}
.second {
border-top:3px solid red;
border-left:3px solid green;
border-right:3px solid green;
}
</style>
<table>
<tr>
<td class='first'>Virsraksts 1</td>
<td class='second'>suna 1</td>
<td class='second'>suna 2</td>
</tr>
<tr>
<td class='first'>Virsraksts 2</td>
<td class='second'>suna 3</td>
<td class='second'>suna 4</td>
</tr>
<tr>
<td class='first'>Virsraksts 3</td>
<td class='second'>suna 5</td>
<td class='second'>suna 6</td>
</tr>
</table>
Related
How can I add a little square at the bottom right of a table cell?
It just like a selected cell in excel.
I have tried to add a div in the cell, however, it makes the content does not be placed in the centre of the cell. So, I don't know how to do so.
HTML:
.borderCell
{
border:1px inset #e0e0e0;
}
.borderCell:after
{
border:2px inset transparent;
}
.dateCell
{
padding: 0px;
font-size:17px;
width:25px;
}
<table>
<tr>
<td class="borderCell alignCenter" contenteditable="true">
b
<div style="width:5px;height:5px;background-color:blue;float:right"></div>
</td>
</tr>
</table>
table {
border-collapse: collapse;
}
table,
th,
td {
border: 1px solid black;
}
th,
td {
padding: 10px;
}
td.parentsqure {
position: relative;
}
.squre {
height: 5px;
width: 5px;
background: red;
position: absolute;
right: 0;
bottom: 0;
}
<table>
<tr>
<td>test 1</td>
<td class="parentsqure">
test 2
<div class="squre"></div>
</td>
<td>test 3</td>
</tr>
</table>
No need to consider an extra element, use a simple background:
table {
border-collapse: collapse;
}
table,
th,
td {
border: 1px solid black;
}
th,
td {
padding: 10px;
}
td.parentsqure {
background: linear-gradient(red,red) bottom right/5px 5px no-repeat;
}
<table>
<tr>
<td>test 1</td>
<td class="parentsqure">
test 2
</td>
<td>test 3</td>
</tr>
</table>
I have this code where I am trying to color all 4 sides of a TD cell with red, but if you run the code, only the bottom and the right border are getting color (in Mozilla Firefox). Is there a way to color all 4 borders?
#selections_table table {
border-collapse: collapse;
}
#selections_table td,
th {
border: 1px solid black;
padding: 3px 4px 3px 4px;
}
<div id="selections_table">
<table>
<tbody>
<tr>
<th>#</th>
<th>Model</th>
</tr>
<tr>
<td>1</td>
<td style="border-color:red">XXX-8</td>
</tr>
</tbody>
</table>
</div>
This question/answer does not help: CSS Border declare 4 sides, color, width, in one line
If there is a way to style it via a class, that will be better than using a an inline style command.
Change your inline style to style="border:1px double red;":
<div id="selections_table">
<table>
<tbody>
<tr>
<th>#</th>
<th>Model</th>
</tr>
<tr>
<td>1</td>
<td style="border:1px double red;">XXX-8</td>
</tr>
</tbody>
</table>
</div>
A little trick, create an ::after to the td you want to add the border.
#selections_table table {
border-collapse: collapse;
}
#selections_table td,
th {
border: 1px solid black;
padding: 3px 4px 3px 4px;
position:relative;
}
#selections_table td.border-red::after{
content: "";
position: absolute;
top: -1px;
left: -1px;
right: -1px;
bottom: -1px;
border: 1px solid red;
}
<div id="selections_table">
<table>
<tbody>
<tr>
<th>#</th>
<th>Model</th>
</tr>
<tr>
<td>1</td>
<td class="border-red">XXX-8</td>
</tr>
</tbody>
</table>
</div>
https://jsfiddle.net/ym82a0k7/
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid red;
}
</style>
</head>
<body>
<div id="selections_table">
<table>
<tbody>
<tr>
<th>#</th>
<th>Model</th>
</tr>
<tr>
<td>1</td>
<td>XXX-8</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
First, you don't need to declare td here:
#selections_table td,th {
border: 1px solid black;
padding: 3px 4px 3px 4px;
}
So,
#selections_table th {
border: 1px solid black;
border-bottom: 1px solid red;
padding: 3px 4px 3px 4px;
}
td {
border: 1px solid red;
}
This is another option (by increasing the pixel, it is not a good practice but another option)
#selections_table th {
border: 1px solid black;
padding: 3px 4px 3px 4px;
}
td {
border: 2px solid red;
}
or just like this:
#selections_table th {
border: 1px solid black;
padding: 3px 4px 3px 4px;
}
td {
border: 1px double red;
}
I have HTML table with rowspan and I want to td with different boarder-left color
HTML Code;
<table class="table">
<tr>
<td class ="fail-td" rowspan="2">Detail</td>
<td class ="fail-td">Data 1</td>
<td class="event">Event</td>
</tr>
<tr> <td class ="success-td">Data 2</td></tr>
</table>
Snippet:
.fail-td {
border-left: 4px solid #d9534f !important;
}
.success-td {
border-left: 4px solid #5cb85c !important;
}
Expected output is rowspan second row td with green color left border
But result is td with red color left border
set fail-td class name of second td of data 1 value
.fail-td {
border-left: 4px solid #d9534f !important;
}
.success-td {
border-left: 4px solid #5cb85c !important;
}
<table class="table">
<tr>
<td class="fail-td" rowspan="2">Detail</td>
<td class="fail-td">Data 1</td>
<td class="event">Event</td>
</tr>
<tr>
<td class="success-td">Data 2</td>
</tr>
</table>
table tr td:nth-child(1) {
border-left: 4px solid green;
}
table tr td:nth-child(2) {
border-left: 4px solid red;
}
table tr td:nth-child(3) {
border-left: 4px solid yellow;
}
table tr td:nth-child(4) {
border-left: 4px solid blue;
}
<!-- language: lang-html -->
<table class="table">
<tr>
<td rowspan="2">Detail</td>
<td>Data 1</td>
<td class="event">Event</td>
</tr>
<tr>
<td>Data 2</td>
</tr>
</table>
<!-- end snippet -->
I have a html table, my top-left cell is empty and I want to remove its border.
I tried with some css:
.border-less {
border-top: 1px solid #FFFFFF;
border-left: 1px solid #FFFFFF;
}
That I applied to my top left cell:
<td class="border-less"></td>
but it doesn't work.
Any idea how to achieve this?
Remove border from table and tr and apply border only for td.
table {
border-collapse: collapse;
}
td {
border: 1px solid grey;
}
td.border-less {
border: none;
}
<table>
<tr>
<td class="border-less"></td>
<td>22</td>
<td>33</td>
</tr>
<tr>
<td>11</td>
<td>22</td>
<td>33</td>
</tr>
<tr>
<td>11</td>
<td>22</td>
<td>33</td>
</tr>
</table>
Try like this: Demo
table tr.border-less>td {
border-top: 0px solid #FFFFFF;
border-left: 0px solid #FFFFFF;
}
check out this
CSS
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
.border-less {
border-top: 1px solid #FFFFFF;
border-left: 1px solid #FFFFFF;
}
http://jsfiddle.net/vasanthanvas/jfvhxy59/
The following code, in all browsers - apart from Google Chrome Latest on the PC - displays a border on the tbody table cells, as specified in the CSS.
Chrome PC, displays the thead border, but not the TD borders. Why? Is it a bug in Chrome, or in my HTML/CSS?
Heres a jsFiddle that replicates it:
<table width="505" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td>Testing</td>
<td>123</td>
</tr>
<tr>
<td>Testing</td>
<td>456</td>
</tr>
</tbody>
<thead>
<tr>
<th>foo</th>
<th>bar</th>
</tr>
</thead>
table {
width:736px;
border-collapse: collapse;
thead {
border-top: 2px solid #aaaaaa;
tr {
th {
border: 0;
padding: 12px 5px;
}
}
}
tbody {
border-top:0;
tr {
td {
padding: 10px 5px;
border-top: 1px solid #aaaaaa;
border-bottom: 1px solid #aaaaaa;
}
}
Try with putting tbody after thead.
HTML
<table width="505" cellspacing="0" cellpadding="0" border="0">
<thead>
<tr>
<th>foo</th>
<th>bar</th>
</tr>
</thead>
<tbody>
<tr>
<td>Testing</td>
<td>123</td>
</tr>
<tr>
<td>Testing</td>
<td>456</td>
</tr>
</tbody>
</table>
JSFiddle
From MDN:
thead - A table element. The thead must appear after any caption or colgroup element, even implicitly defined, but before any tbody, tfoot and tr element.
Remove border-collapse: collapse and use border-top for TD and border-bottom for TABLE.
Live demo
Try this.
table {
width:736px;
border-collapse: collapse;
}
thead {
border-top: 2px solid #aaaaaa;
}
th {
border: 0;
padding: 12px 5px;
}
tbody {
border-top:0;
}
td {
padding: 10px 5px;
border-top: 1px solid #aaaaaa;
border-bottom: 1px solid #aaaaaa;
}
I had a table using -webkit-backface-visibility:hidden;, which was hiding border color, so to fix I used -webkit-backface-visibility:visible;.