Unexpected transparent gap between columns in a table - html

There are some strange transparent gaps between columns in a table
Here is css
div.table-container{
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 500px;
background-color:colors.$lighter_blue;
position: relative;
div.table-wrapper{
width: 80%;
height: 70%;
padding: 0;
margin: 0 auto;
font-size: 15px;
position: absolute;
overflow: auto;
scrollbar-width: thin; //for FireFox
box-shadow: 0px 0 5px 1px rgb(0 0 0 / 30%);
table.securities-table{
width: 100%;
background-color: white;
border-collapse: separate;
border-spacing: 0;
padding:0;
margin:0;
th,td{
padding: 5px 10px;
}
tbody{
tr:nth-child(odd){
background-color: #f2f2f2;
}
}
th{
color: white;
background-color: colors.$light-blue;
text-align: left;
position: sticky;
top: -1px;
z-index: 1;
}
}
}
}
here is HTML
const securitiesTableHeader = () => {
return (
<thead>
<tr>
{securitiesHeader.map((header,i) =>
<th key={header+i}>{header.headerName}</th>)
}
</tr>
</thead>
);
}
const securitiesTableCols = (row) => {
return (
securitiesHeader.map((header,i) =>
<td key={row[header.value]+"_"+i}>
{getColumnValue(row, header.value)}
</td>)
)
}
const securitiesTableRows= () => {
return (
<tbody>
{
securitiesJSON.map((obj,i) =>
<tr key={"row_"+i}>
{securitiesTableCols(obj)}
</tr>
)}
</tbody>
);
}
return (
<div className = "table-container">
<div className={`table-wrapper`}>
<table className= {`securities-table`}>
{securitiesTableHeader()}
{securitiesTableRows()}
</table>
</div>
</div>
I have tried border-collapse: collapse or separate with border-spacing: 0 but it couldn't remove those "transparent" gaps. Even weirder, those gaps appear and disappear randomly without any specific order/pattern. I only see that in Chrome in mobile view mode in Developer Tools(Chrome inspect) and as far as I know, I didn't see that from Firefox or Edge. I suspect that it is a bug from Chrome but I am quite sure. If anyone has seen this before, I appreciate if you could help me solve this.

div.table-wrapper{
width: 80%;
height: 70%;
padding: 0;
margin: 0 auto;
font-size: 15px;
overflow: auto;
scrollbar-width: thin; //for FireFox
table.securities-table{
width: 100%;
background-color: white;
border-collapse: separate;
border-spacing: 0;
padding:0;
margin:0;
th,td{
padding: 5px;
}
tbody{
tr:nth-child(odd){
background-color: #f2f2f2;
}
}
th{
color: white;
background-color: colors.$light-blue;
text-align: left;
top: -1px;
}
}
}

Related

To reduce the cell/row height of an HTML table row in Blazor

I have a very simple html table in a Blazor server project and I am trying to reduce the space below the text in the cell. Changing height in the td,th section increases the standard height but does not reduce it. I have tried making margin and padding 0 but this did not reduce the space.
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
font-size: 12px;
padding: 0px;
margin: 0px;
}
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 0px;
margin: 0px;
height: 12px;
padding-bottom: 0px;
margin-bottom: 0px;
}
td {
padding: 0px;
margin: 0;
height: 10px;
padding-bottom: 0px;
margin-bottom: 0;
}
tr:nth-child(even) {
background-color: #dddddd;
}
tr {
height:2px;
padding: 0px;
}
</style>
What you are looking for is line-height
<table>
<tr class="loose">
<th>Title</th>
</tr>
<tr class="tight">
<td>Cell</td>
</tr>
</table>
<style>
tr.loose { line-height: 4rem;}
tr.tight { line-height: 1.5rem;}
</style>
Demo: https://blazorrepl.com/repl/GbEnmGcn38GdDUWW44

IE11: Extend table row beyond table on hover

I have an HTML table inside a container. On hover, I want to highlight the row, not only inside the table, but extending outside to the edges of the container.
This is my first attempt:
body {
display: flex;
justify-content: center;
}
.container {
display: flex;
justify-content: center;
width: 800px;
border: 1px dotted gray;
padding: 2rem;
}
table {
table-layout: fixed;
border-collapse: collapse;
width: 100%;
border: 1px dashed purple;
}
td, th {
padding: .25rem;
position: relative;
text-align: left;
}
tr:hover {
background: lightgray;
cursor: pointer;
}
tr:hover td:first-child::before, tr:hover td:last-child::after {
content: '';
position: absolute;
top: 0;
bottom: 0;
width: 2rem;
background-color: lightgray;
}
td:first-child::before {
left: -2rem;
}
td:last-child::after {
right: -2rem;
}
<div class="container">
<table>
<thead>
<th>Dato</th>
<th>Lok. nr.</th>
<th>Navn</th>
<th>Status</th>
</thead>
<tbody>
<tr>
<td>06.12.2016</td>
<td>25736</td>
<td>Josommar-<br>set</td>
<td>I arbeid</td>
</tr>
<tr>
<td>07.12.2016</td>
<td>10232</td>
<td>Mannbru-<br>holmen</td>
<td>Avsluttet</td>
</tr>
</tbody>
</table>
</div>
It works fine in Chrome, but I have to support IE11, and in IE the before and after elements do not have the correct height. You can see the result in the screenshot below.
How can I do this in a way that also works in IE11?

HTML: Set scroll on div table-row

Hello i try to set scroll in .chat .body (overflow-y: scroll), i try every code but not work.
thanks in advance !
////////////////////////////////////////
Code:
<div class="chat">
<div class="head"></div>
<div class="body">
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td align="left" width="40">
<img src="http://www.exclutips.com/wp-content/uploads/2015/08/wordpress-custom-user-avatar.png" style="
width: 32px;
height: 32px;
display: block;
border: 1px solid rgba(0, 0, 0, .1);
cursor: pointer;
">
</td>
<td align="left" width="136">
<div class="user-name">User Name</div>
</td>
<td align="right">
<span class="online-icon"></span>
</td>
</tr>
</tbody>
</table>
</div>
<div class="footer">
<input type="text" placeholder="Search">
</div>
</div>
<style type="text/css">
* { font-family: "Segoe UI"; }
html {
font-size: 100%;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
height: 100%;
}
body {
margin: 0;
padding: 0;
background: #F2F2F2;
height: 100%;
}
input, select {
display: block;
width: 100%;
padding: 5px;
outline: none;
border-width: 1px;
border-style: solid;
border-radius: 0;
background: #fff;
font-size: 12px;
color: #6B6B6B;
appearance:normal;
-moz-appearance:none;
-webkit-appearance:none;
border-color: #BDBDBD;
}
div, textarea, input, select, button, a { box-sizing: border-box; -moz-box-sizing: border-box; }
.chat {
display: table;
border-left: 1px solid #ccc;
position: fixed;
height: 100%;
top: 0;
right: 0;
bottom: 0;
width: 200px;
margin: 0;
padding: 0;
background: #E1E1E1;
}
.chat .head {
display: table-row !important;
height: 52px;
}
.chat .body {
overflow-y: scroll;
display: table-row;
height: 100% !important;
}
.chat .body table {
cursor: pointer;
padding: 5px;
}
.chat .footer {
display: table-row !important;
}
</style>
Check demo here: http://chatiiii.hol.es/default.php
You can use jQuery to set .body height :
* {
box-sizing:border-box;
...
}
.chat {
display: block;
...
}
.chat .head {
height: 52px;
...
}
.chat .body {
overflow-y: auto;
...
}
and jQuery
$(document).ready(function () {
setSize();
$(window).on('resize',setSize);
});
function setSize(){
var CH = $('.chat').height(),
HH = $('.chat .head').height(),
FH = $('.chat .footer').height();
$('.chat .body').height(CH-HH-FH);
}
see full example here.
Remove display: table-row; from .chat .body.
use this style for .chat .body class , but you should duplicate user table in html until it come more than page's height , then you can see scroll comes.
.chat .body {
overflow-y: scroll;
height: 80%;
}
You should remove display: table-row , and also give a height less than 100% .

Provides between the text content and my footer bar

I am going to make so that you can turn things up on the website like facebook, but this is how I have come into problems with my text content and my footer bar where it just gives some air in between these two.
Html here:
<div class="statusOpslag">
<asp:TextBox ID="TextBoxStatusTekst" CssClass="statusTekst" runat="server" TextMode="MultiLine"></asp:TextBox>
<div class="Statusfooter">
<asp:Button ID="ButtonSend" OnClick="ButtonSend_Click" runat="server" Text="Slå op" CssClass="statusKlikButtonOUT" />
</div>
</div>
CSS here
.statusOpslag {
background: #ffffff;
margin-bottom: 30px;
margin-top: 0;
margin: 10px;
padding: 0;
width: 95%;
}
.statusTekst {
width: 100%;
overflow: hidden;
word-wrap: break-word;
height: 120px;
max-height: 120px;
margin:0;
}
.Statusfooter {
background: #F4F4F4;
padding: 15px;
margin:0px;
}
.statusKlikButtonOUT {
background-color: #5cb85c;
border: 0;
color: green;
}
You can see it problems here
EIDT CSS
I have done as you have described in your answer and it helps nothing. - sorry
.statusOpslag {
background: #ffffff;
padding: 0;
margin: 0;
}
.statusTekst {
width: 100%;
overflow: hidden;
word-wrap: break-word;
height: 120px;
max-height: 120px;
margin:0;
}
.Statusfooter {
background: #F4F4F4;
padding: 15px;
margin:0px;
}
.statusKlikButtonOUT {
background-color: #5cb85c;
border: 0;
color: green;
}
Get rid of all the margins you set. Then, add this in css:
*{
margin: 0:
padding: 0:
}
Once it's set, you don't need to set
margin: 0;
No where again.
Also, in your statusOpslog class you set margin twice:
margin: 10px;
margin-bottom: 30px;
You should only set it once.
If you do not want that margin you got in your question you should not set margin at all for that element.

Table margin is weird

I would like to give the table a margin, that the table is not 100% of the #content div. But the table is bigger than the div(outside).
Here is my fiddle: jsfiddle
HTML code:
</form>
<table>
<tr>
<th>Jobart</th>
<th>Stadteil</th>
<th>Berufsfeld</th>
<th>Title</th>
<th>Vergütung</th>
<th>Gesucht zum(Datum)</th>
<th>Weitere Informationen</th>
</tr>
<tr>
<td>Gelegenheitsjob</td>
<td>Charlottenburg</td>
<td>Bau, Architektur, Vermessung</td>
<td>kl</td>
<td></td>
<td>0000-00-00</td>
<td>Weiter</td>
</tr>
<tr>
<td>Gelegenheitsjob</td>
<td>Charlottenburg</td>
<td>Bau, Architektur, Vermessung</td>
<td>kljlk</td>
<td>78678</td>
<td>2014-12-01</td>
<td>Weiter</td>
</tr>
<tr>
<td>Ausbildungsplatz</td>
<td>Lichtenberg</td>
<td>Gesundheit</td>
<td>kökölkölk</td>
<td>321321</td>
<td>2014-12-23</td>
<td>Weiter</td>
</tr>
<tr>
<td>Praktika</td>
<td>Tempelhof</td>
<td>Technik, Technologiefelder</td>
<td>hallo</td>
<td>1337€</td>
<td>2014-12-25</td>
<td>Weiter</td>
</tr>
<tr>
<td>Praktika</td>
<td>Reinickendorf</td>
<td>Medien</td>
<td>jljlkjljkl</td>
<td>7987987</td>
<td>2014-12-28</td>
<td>Weiter</td>
</tr>
</table>
CSS code:
* {
margin: 0;
padding: 0;
}
body {
background-color: gray;
width: 100%;
}
#header {
background-color: blue;
height: 250px;
width: 100%;
}
nav {
width: 100%;
height: 50px;
background-color: yellow;
}
nav ul {
margin: 0;
}
nav ul li {
list-style: none;
float: left;
display: block;
margin: 8px 0 0 50px;
}
nav a:link {
text-decoration: none;
color: #696969;
font-family: 'Oswald', sans-serif;
font-size: 22px;
}
nav a:visited {
color: #696969;
}
nav a:hover {
color: black;
}
nav a:active {
color: black;
}
#content {
clear: left;
background-color: white;
width: 100%;
height: 100%;
}
form {
padding: 30px;
}
table {
width: 100%;
margin: 30px;
border-collapse: collapse;
/*border-spacing: 8px;*/
}
table tr:nth-of-type(odd) td {
background-color: gray;
}
th {
background-color: #8dc043;
height: 50px;
border: 1px solid #578415;
}
tr {
border: 1px solid #578415;
}
td {
border: 1px solid #578415;
padding: 8px;
}
fieldset {
padding: 15px;
}
footer {
border: 1px solid red;
background-color: green;
height: 50px;
}
footer ul {
margin: 15px 0 0 0;
}
footer ul li {
list-style: none;
float: left;
display: block;
margin: 0 0 0 50px;
}
#wrapper {
margin: 0 auto;
width: 85%;
}
Hope, that somebody can help me!
The problem is that in your example the padding: 30px of your table is added to width: 100% which results in more than 100% of total width;
Example 1: Using percentages on table
HTML
<table>
...
</table>
CSS
table {
margin: 3%;
width: 94%;
}
Example 2 Using wrapper around table for pixelvalues
HTML
<div class="tablemargin">
<table>
...
</table>
</div>
CSS
.tablemargin {
margin: 30px; /*sets margin around the table*/
}
table {
width: 100%;
margin: 0; /*set margin to 0 or remove this property completely*/
}
You can use pixel size as well as percentages. 50px is 50 pixels. It would be like this:
nav {
width: 100px;
height: 50px;
background-color: yellow;
}