Html,css: double border on table's rows - html

I am trying to "copy" http://grooveshark.com/#!/album/Halo+LP/5904939 this table right here.
This is my attempt http://jsfiddle.net/d1zqsayh/25/
Problem with my code is that somehow, when you hover over <tr>s and the bottom border is double (2px up from 1)
I tried adding border-collapse: collapse; in my code and didn't fix it as a stack overflow post suggested.
Maybe i am doing it wrong.
Can someone try and make this work ?
I have put all the important .css rows on the top 63 lines.
Note: I am using DataTables

Grooveshark does not use a table layout, they have a <div> for each row with -1px top margin, so on hover it will overlap the row above.
You can use however the element+element adjacent sibling selector to achieve the same thing. First, only use top borders and on hover, with the element+element selector, change the border color of the next row:
table.dataTable tbody tr td{
border-top: 1px solid #dddddd;
}
table.dataTable tbody tr:hover td {
border-top: 1px solid rgb(192, 220, 255);
}
table.dataTable tbody tr:hover + tr td {
border-top: 1px solid rgb(192, 220, 255);
}
Example: http://jsfiddle.net/d1zqsayh/26/

Related

Border assigned over TD is not working in IE

I have a Table in which there are TD's. In one of those td's, I am applying border. It is
working fine in CHROME, but its getting disturbed in IE.
NOTE:- Earlier, when the cellpadding of the table was 2 it was looking fine but when I increased the cellpadding the border got disturbed.
Here is how it looks like
and here is the fiddle
what should I do to make it work in IE
Do you mean you want it looking like this?
https://jsfiddle.net/Hastig/o1j88quk/3/
If so add table { border-collapse: collapse; } to your css.
May also have to remove cellspacing="10" from inline style of table
To remove middle line
change
tr.black-border td {
border-top: 1px solid #0D63B0;
border-bottom: 1px solid #0D63B0;
}
to
tr.black-border:nth-child(3) td {
border-top: 1px solid #0D63B0;
}
tr.black-border:nth-child(4) td {
border-bottom: 1px solid #0D63B0;
}
Alternatively, you can control the border style by adding classes, if old IE has a problem with nth-child(x)

Table right border (bootstrap + custom css)

I'm using bootstrap 2.3 version and some custom CSS styles. I got next problem: when I try to add right border to the last td in row it is not displayed. But it is displayed when I zoom browser window, or if I set width to 2px. I use chrome but it seems like in firefox there is the same issue.
Jsfiddle example: http://jsfiddle.net/Ct7dC/
CSS:
table.entity-table > tbody > tr > td:last-child {
border-right: 1px solid #DDD; /* It works only if I set 2px width. Also works with 1px width but if I zoom browser window */
}
Also noticed that when I zoom the page table left and right borders become not straight
For the border-right not being smooth is duo the th ontop of it has no extra width from the border(it simply has no border), because the row has gaint some extra width because the border-right is no inline border. You can fix this by ginving the th also a border.
table.entity-table > thead > tr > th
{
background-color: #DDD;
color: #000;
border: 1px solid #DDD;
}
jsFiddle
Now for the Ubuntu problem. I don't know if you use a variant of chrome(like chromium)?
Edit
The fiddle also works on chromium windows, so certainly has to do something width ubuntu.
Like this
demo
css
table.entity-table > tbody > tr > td {
vertical-align: middle;
border-left: 1px solid #DDD;
}

Table row and borders

I have stuck in a point when I convert a psd to html/css
The page is this : http://valogiannis.com/freelancer/neurosport/editdetails.html
Below the title "Edit Account Details" I have a table to show the user data.
I have I have the following rule for the rows
#editAccountDetails tr {
border-bottom:#cdd3e0 solid 1px;
border-top:#fff solid 1px;
line-height:3;
}
As you can see in the page the blue bottom-border overlap the white border-top. I get the same result in all browser so I suppose is normal behavior and it's something that I can't understand.
What I want to achieve is the border-bottom to be exactly above the white border-top. Any suggestion?
P.S Something else that would help me if you know. How can I make the border-bottom don't appear for the latest row and border-top for the first row? I think it's something like tr + tr {... } but I don't remember exactly.
The reason you cant see your borders is because this is in your reset.css
table {
border-collapse: collapse
}
add in this to your css
#editAccountDetails table {
border-collapse: seperate
}
You will also need to remove the borders from the tr to the td
#editAccountDetails td {
border-bottom:1px solid #CDD3E0;
border-top:1px solid #FFFFFF;
}
And the selector for the first row is:
#editAccountDetails tr:first-child {color:blue}
And the selector for the last row is: (last row doesnt work in ie)
#editAccountDetails tr:last-child {color:blue}
table {
border-collapse: collapse
}
try this
Simply put borders on the TD instead of TR and all will be well :-)
#editAccountDetails tr td {
border-bottom:#cdd3e0 solid 1px;
border-top:#fff solid 1px;
line-height:3;
}

Set inner table border in HTML

How do I set the "inner border" - the border between different cells.
By setting style attributes I manage to control the outer border, but the inner border just stays the same gray color and the same width. What attributes should I tweak to control the inner border?
For ordinary table markup, here's a short solution that works on all devices/browsers on BrowserStack, except IE 7 and below:
table { border-collapse: collapse; }
td + td,
th + th { border-left: 1px solid; }
tr + tr { border-top: 1px solid; }
For IE 7 support, add this:
tr + tr > td,
tr + tr > th { border-top: 1px solid; }
A test case can be seen here: http://codepen.io/dalgard/pen/wmcdE
You need to style the <td> element.
Take a look at the W3C website

Why is Firefox missing the border on some HTML tables

I am using Firefox 3.5.7 and I have the same CSS used in multiple HTML tables, but there are some examples where parts of the borders are not shown.
What makes no sense to me is that the same CSS on the same page for another HTML table works fine. Also, the same page in Internet Explorer looks fine from a border point of view.
Here is an image with an example, as you can see in this case the bottom of the first table is missing a border.
Does anyone have a clue why this would happen here?
Maybe you've zoomed in/out a bit. This can happen either accidently or knowingly when you do Ctrl+Scrollwheel. Maybe it isn't completely resetted to zoom level zero. This mis-rendering behaviour is then recognizeable at some websites, also here at SO.
To fix this, just hit Ctrl+0 or do View > Zoom > Reset to reset the zoom level to default.
This is Firefox/Gecko bug 410959. This affects tables with border-collapse:collapse. It's from 2008 and there's no real progress on it, so you'll probably need to find a workaround. One way is using border-collapse:separate and fiddling with borders on a per-cell basis.
I found a similar problem when zoomed out in Firefox on an application I am working on.
The main cause was having the CSS border-collapse property set to collapse.
Changing it to separate instead fixed the problem. However, that meant I did have to rethink the way borders are applied to various parts of the table, because otherwise your borders will appear to double in thickness. I ended up having to use jQuery to give a special "last" class to the last td or th in each tr, and to the last tr in the table. My query was something like:
$('table tr > th:last-child, table > tbody > tr > td:last-child, table > tbody > tr:last-child').addClass('last');
My CSS rules were similar that:
table
{
border-collapse: separate !important;
}
table tr, table th, table td
{
border-right-width: 0;
border-bottom-width: 0;
border-left: 1px solid black;
border-top: 1px solid black;
}
table td.last, table th.last
{
border-right: 1px solid black;
}
table tr.last td
{
border-bottom: 1px solid black;
}
table
{
border: 0;
}
I did end up using browser targeting so that I only applied these rules to Firefox users, but it may work for all browsers, I haven't tested.
Building on the good answer of #GregL (I seem unable to "comment" directly on it):
Instead of using JQuery to generate a "last" class, I simply used the built-in pseudo-element selector :first-child. I built rules selecting tr:first-child and td:first-child that define border-top and border-left (instead of border-right and border-bottom as in GregL's answer). The generic rules define border-right and border-bottom instead of border-left and border-top. :first-child is said to be supported in Chrome v. 4.0, Firefox v. 3.0, IE 7.0, Safari v. 3.1, and Opera v. 9.6 (). Tested on Firefox v. 40.0.3, where I saw this problem in the first place.
This was caused by the table (with a missing bottom-border) to be inside a div...The border apparently didn't get calculated in the table height, so the border was there but wasn't shown.
Giving the surrounding div a margin-bottom from 1px solved the problem.
Just use border-spacing:0; hope this will solve your problem.
Border started going missing when browser zoom was increased. I was able to solve it by doing the following. Tested in Chrome and Firefox.
padding: 0.5px !important
I had the same problem with missing table border.
My solution is:
table{
border-collapse: collapse !important;
border-spacing: 0px;
border: 1px solid #DDD;
}
And border for table rows:
table tr{
border-bottom: 1px solid #DDD !important;
}
I am using Bootstrap either in my layout and the table has also bootstrap css classes like "table table-striped table-bordered"
This solution works for me, when I tried solution with
border-collapse: separate !important;
it didn't work properly for me.
worked for me realisation of answer #Donald Payne
*( .table - bootstrap class )
table.table {
border-collapse: separate !important;
}
table.table tr,
table.table th,
table.table td {
border-right-width: 0 !important;
border-bottom-width: 0 !important;
border-left: 1px solid #DDD !important;
border-top: 1px solid #DDD !important;
}
table.table td:last-child,
table.table th:last-child {
border-right: 1px solid #DDD !important;
}
table.table tr:last-child td {
border-bottom: 1px solid #DDD !important;
}
table.table {
border: 0 !important;
}
table.table thead tr:last-child th,
table.table thead tr:last-child td {
border-bottom: 1px solid #DDD !important;
}
table.table tbody tr:first-child th,
table.table tbody tr:first-child td {
border-top-width: 0 !important;
}
This is a bit tangential, but for those searching for missing borders in Firefox…
I had a border-bottom of a table-row (<tr>) that was missing where a background had been set on a specific cell. It turned out this was caused by a rogue position: relative on the cell, removing that (or changing it to position: inherit) fixed it.
Firefox 70.0.1