I am seeking for better way to arrange my borders.
Currently I have something like this, but I feel there must be some better and quick solution to this.
My Code:
<style>
td.left{
border-top-style:solid;
border-left-style:solid;
border-bottom-style:solid;
border-color: black;
border-width: 1px;
}
td.right{
border-top-style:solid;
border-right-style:solid;
border-bottom-style:solid;
border-color: black;
border-width: 1px;
}
td.updown{
border-top-style:solid;
border-bottom-style:solid;
border-color: black;
border-width: 1px;
}
td.left2{
border-left-style:solid;
border-bottom-style:solid;
border-color: black;
border-width: 1px;
}
td.right2{
border-right-style:solid;
border-bottom-style:solid;
border-color: black;
border-width: 1px;
}
td.updown2{
border-bottom-style:solid;
border-color: black;
border-width: 1px;
}
td.finish{
border-bottom-style: solid;
border-left-style: solid;
border-right-style: solid;
border-color: black;
border-width: 1px;
}
table {
border-style:none;
padding:1px;
margin:0px;
border-spacing: 0px;
border: 0pxborder: ;
width:850px;
}
</style>
I have created classes with each specific side to be displayed for each different purposes.
Here is the body part of the code, I have used class "left" for 1st row and "left2" for 2nd row, this is due to if I use both rows with "left" then second row will have thicker line between 1st row and 2nd row.
In this table I want to make lines between a specific column to disappear or appear but struggling to find shorter code to do so.
<table>
<tbody>
<tr>
<td width="149" class="left"> For testing 1</td>
<td width="312" class="updown"><input type="text" /></td>
<td width="172" class="left"> For testing 2</td>
<td width="204" class="right"> <input type="text" /></td>
</tr>
<tr>
<td class="left2">For testing 3</td>
<td class="right2" colspan="3"><input type="text" /></td>
</tr>
<tr>
<td class="left2" colspan="2">For testing 4</td>
<td class="finish" colspan="2"><input type="text" /></td>
</tr>
</tbody>
</table>
Here is a character-saving solution with border-collapse: collapse;
LIVE DEMO
HTML:
<table>
<tbody>
<tr>
<td><span>For testing 1</span><input type="text" /></td>
<td><span>For testing 2</span><input type="text" /></td>
</tr>
<tr>
<td colspan="2"><span>For testing 3</span><input type="text" /></td>
</tr>
<tr>
<td><span>For testing 4</span></td>
<td><input type="text" /></td>
</tr>
</tbody>
</table>
CSS:
td {
border: 1px solid black;
border-collapse: collapse;
}
table {
border: 1px solid black;
border-collapse: collapse;
width: 850px;
}
span {
float: left;
width: 150px;
}
What you could do is this:
td {
border:1px solid black;
}
td.left{
border-right-style:none;
}
td.right{
border-left:none;
}
td.updown{
border-left:none;
border-right:none;
}
td.left2{
border-top:none;
border-right:none;
}
td.right2{
border-left:none;
border-top:none;
}
td.updown2{
border-top:none;
border-left:none;
border-right:none;
}
td.finish{
border-top:none;
}
See: http://jsfiddle.net/Cuyxh/
However, I would suggest using classes for each border in your HTML, for a more modular approach.
Example:
b-left, b-right, b-top, b-down {
border-color:black;
border-width:1px;
}
b-left {
border-left-style:solid;
}
b-top {
border-top-style:solid;
}
b-right {
border-right-style:solid;
}
b-bottom {
border-bottom-style:solid;
}
And then adding these classes to your table cells. For example:
<td width="149" class="b-left b-top">For testing 1</td>
Related
How can I change the radius of thead and tr element? I want my table to have rounded corners but border-radius is not working for thead and tr but its works for the element itself. Here is the CSS.
table{
width:100%;
border-radius:5px;
background:gray;
}
thead {
border-radius:5px;
text-align:left;
background:blue;
}
tr{
border-radius:5px;
}
th,td{
padding:5px;
}
Here is the HTML.
<table>
<thead>
<tr>
<th>No</th>
<th>Name</th>
<th>Country</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Andy</td>
<td>UK</td>
<td>40</td>
</tr>
</tbody>
<tbody>
</table>
This is fairly easy to do. You need to add the border radius to the correct corners of the first and last th in the row rather than the thead like this:
th:nth-child(1) {
border-radius: 5px 0px 0px 0px;
}
th:nth-last-child(1) {
border-radius: 0px 5px 0px 0px;
}
Here is a full code snippet:
table{
width:100%;
border-radius:5px;
background:gray;
}
tr{
border-radius:5px;
}
th,td{
padding:5px;
}
th{
text-align:left;
background:blue;
color: #fff;
}
th:nth-child(1) {
border-radius: 5px 0px 0px 0px;
}
th:nth-last-child(1) {
border-radius: 0px 5px 0px 0px;
}
<table>
<thead>
<tr>
<th>No</th>
<th>Name</th>
<th>Country</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Andy</td>
<td>UK</td>
<td>40</td>
</tr>
</tbody>
<tbody>
</table>
radius needs to be in a th or td so i'd do something like this:
table{
width:100%;
border-radius:5px;
background:gray;
border-collapse: separate;
}
table th {
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
text-align:left;
background:blue;
}
table td{
border-radius:5px;
}
th,td{
padding:5px;
}
td {
border: solid 1px #000;
border-style: solid none;
padding: 10px;
background-color: cyan;
}
td:first-child {
border-left-style: solid;
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
}
td:last-child {
border-right-style: solid;
border-bottom-right-radius: 10px;
border-top-right-radius: 10px;
}
<table>
<thead>
<tr>
<th>No</th>
<th>Name</th>
<th>Country</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Andy</td>
<td>UK</td>
<td>40</td>
</tr>
</tbody>
<tbody>
</table>
You need to add "th" in the css. Then you have to use "border-radius".
thead th{
border-radius: 10px 10px 10px 10px;
text-align:left;
background:blue;
}
Add "border-radius" in td too.
td{
border-radius: 10px 10px 10px ;
background-color: red;
}
I am using the following plugin.
https://github.com/dabeng/OrgChart.
In some resolution, the vertical line is not fitting properly.
https://github.com/dabeng/OrgChart/issues/410
I have analysed the rendered html and tried with the same code.
I am getting the same issue for some resolutions.
Please see the following fiddler.
.downline{
height:30px;
width:2px;
background:red;
text-align:center;
background: red;
text-align: center;
background-color: rgba(217, 83, 79, 0.8);
margin: 0px auto;
height: 55px;
width: 2px;
float: none;
}
.leftLine{
border-right:1px solid green;
}
.rightLine{
border-left:1px solid green;
}
table{
margin:50px;
border-spacing: 0 !important;
border-collapse: separate !important;
}
.item{
padding:5px;
border:1px solid black;
}
<table>
<tr>
<td colspan="2">
<div class="downline">
</div>
</td>
</tr>
<tr>
<td class="leftLine">
</td>
<td class="rightLine">
</td>
</tr>
<tr>
<td colspan="2" >
<div class="item">
Test 123
</div>
</td>
</tr>
</table>
I'm trying to create a table with 4 columns and at least 12 rows with an overflow-y:scroll. The page is fully responsive. I understand that if I need to add a scrollbar to the table I need to make it display: block on thead as well as tbody. Now the problem that I'm facing is I can't have my trows to have 100% of the width. I've tried to tweak my code for hours now and cannot seem to reach any solution. Attaching the jsfiddle link below
https://jsfiddle.net/kuau4ace/
`
I am only trying to use HTML and CSS with this.
Kindly help!
<table>
By making thead and tbody to display:block you have changed the property of table,thats why tr don't take width:100%.
Try this code
$(document).ready(function(){
var body=$('.template_table').clone();
body.addClass('body');
$('.table-wrapper').append("<div class='table-body'></div>");
$('.table-body').append(body);
var curr = [];
$("table.body th").each(function(i) {
var tColumnWidth = $(this).width();
curr.push(tColumnWidth);
});
$("table:first-child th").each(function(i){
$(this).width(curr[i]);
});
$("table.body thead").empty();
$(".table-wrapper>table tbody").empty();
});
.template_table{
border:1px solid #000;
width:100%;
padding: 0;
}
.template_table thead{
background:#323333;
height: 30px;
width: 100%;
}
.template_table tbody{
height: 210px;
width: 100%;
overflow-x: hidden;
overflow-y: auto;
}
.template_table th{
border:1px solid #000;
border-left:0;
border-right:0
}
.template_table th select{
background:none;
border:none;
border-right:1px solid #323232;
color:#fff;
padding:5px;
width:80%;
}
.template_table th{
width:330px;
}
.template_table th:first-child{
width:80px;
border:1px solid #000;
}
.template_table th:nth-child(2){
width:220px;
border:1px solid #000;
}
.template_table td:first-child{
width:80px;
}
.template_table td:nth-child(2){
width:220px;
}
.template_table td{
width:220px;
color: #c3bfbf;
border-bottom:1px solid #000;
}
.template_table tbody tr:hover td{
background:#676767;
color:#fff;
}
.template_table th{
border:1px solid #000;
border-left:0;
border-right:0;
}
.template_table th select{
background:none;
border:none;
border-right:1px solid #323232;
color:#fff;
padding:5px;
width:80%;
}
.template_table th:first-child{
width:80px;
border:1px solid #000;
}
.template_table th:nth-child(2){
width:220px;
border:1px solid #000;
}
.template_table td:first-child{
width:17%;
}
.template_table td:nth-child(2){
width:37%;
}
.template_table td:nth-child(3) {
}
.template_table td{
color:#807c7c;
border-bottom:1px solid #000;
}
.template_table tbody tr:hover td{
background:#676767;
color:#fff;
}
tbody tr{
cursor:pointer;
}
.table-wrapper {
width: calc(100% - 20px);
}
.table-body {
height: 200px;
overflow-x: hidden;
overflow-y: auto;
width: calc(100% + 15px);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<div class="table-wrapper">
<table class="col-xs-12 template_table">
<thead>
<tr>
<th></th>
<th>
<select>
<option>Page Name </option>
</select>
</th>
<th>
<select>
<option>Template</option>
</select>
</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td>Video Source 1 </td>
<td>Video Clip</td>
</tr>
<tr>
<td></td>
<td>ManningL3 </td>
<td>Player L3</td>
</tr>
<tr>
<td></td>
<td>Boyriven </td>
<td>Talent ID</td>
</tr>
<tr>
<td></td>
<td>Halftime Stats </td>
<td>Full Screen Stats</td>
</tr>
<tr>
<td></td>
<td>Locator </td>
<td>Full Screen Locator</td>
</tr>
<tr>
<td></td>
<td>Locator </td>
<td>Full Screen Locator</td>
</tr>
<tr>
<td></td>
<td>Locator </td>
<td>Full Screen Locator</td>
</tr>
<tr>
<td></td>
<td>Time </td>
<td>Bug</td>
</tr>
<tr>
<td></td>
<td>Singular Info </td>
<td>Topic L3</td>
</tr>
<tr>
<td></td>
<td>Los Angeles</td>
<td>Locator</td>
</tr>
<tr>
<td></td>
<td>Lewandowski </td>
<td>Player L3</td>
</tr>
<tr>
<td></td>
<td>Lewandowski </td>
<td>Player L3</td>
</tr>
</tbody>
</table>
</div>
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>
The mouseover function is not working with Google Chrome. Working fine with Firefox and IE. While mouseover the border bottom is not disappearing. But if removing border-collapse: collapse it's working fine. Why is this? Any solution.
css:
html, body{
margin: 0;
padding: 0;
}
.table {
border-collapse: collapse;
}
.border {
border-style: solid;
border-width: 1px;
border-color: #000000;
background-color: #deecf9;
border-left: 0px;
border-right: 0px;
}
.border1 {
border-style: solid;
border-width: 1px;
border-color: #000000;
background-color: #deecf9;
border-left: 0px;
border-right: 0px;
}
.border2 {
border-style: solid;
border-width: 1px;
border-color: #000000;
background-color: #FFFFFF;
border-left: 0px;
border-right: 0px;
border-bottom: 0px;
padding: 1px;
}
Table:
<table width="1024" border="0" align="center" bgcolor="#FFFFFF" class="table">
<tr>
<td height="9" colspan="4" class="border"></td>
</tr>
<tr>
<td class="border1" onmouseover="this.className='border2'" onmouseout="this.className='border1'"> </td>
<td class="border1" onmouseover="this.className='border2'" onmouseout="this.className='border1'"> </td>
<td class="border1" onmouseover="this.className='border2'" onmouseout="this.className='border1'"> </td>
<td class="border1" onmouseover="this.className='border2'" onmouseout="this.className='border1'"> </td>
</tr>
</table>
Do it like this: put an transparent border on your normal state elements.
When the :hover is applied the size of the border changes the size the element takes up.
eg:
.border1
{
border:1px solid #000000;
border-left:1px solid transparent;
border-right:1px solid transparent;
background-color: #FFFFFF;
}
.border1:hover
{
border:1px solid transparent;
border-top:1px solid #000000;
padding:1px;
background-color: #deecf9;
}
Your HTML should be something like:
<table width="1024" align="center" bgcolor="#FFFFFF" class="table">
<tr>
<td height="9" colspan="4" class="border"></td>
</tr>
<tr>
<td class="border1"> </td>
<td class="border1"> </td>
<td class="border1"> </td>
<td class="border1"> </td>
</tr>
</table>
No need to work with the mouseovers as an attribute, just use css.
Edit: i've noticed that you're using the css border-collapse property. This sets whether the table borders are collapsed into a single border or detached as in standard HTML. Try removing this line or set it to "separate", maybe this will work.