Table margin is weird - html

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;
}

Related

Unexpected transparent gap between columns in a table

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;
}
}
}

Altering background color of button to flow into header on select

I'm trying to altar two buttons (Easy, Hard) on a web app I'm building. I am trying to alter them to remove their borders, and when a button is selected, I want to background to flow up into the header as a visual indication for being selected.
Note: I am linking Bootstrap 4 at the moment.
Current Visual:
Desired Visual:
body {
background-color: #232323;
}
.header {
text-align: center;
color: white;
padding: 1.5rem;
background-color: #66b0c4;
}
.header h1 {
margin: 0;
}
.square {
width: 30%;
background: purple;
padding-bottom: 30%;
float: left;
margin: 1.66%;
}
#container {
max-width: 600px;
margin: 0 auto;
}
#stripe {
background-color: white ;
height: 30px;
text-align: center;
color: black;
}
.selected {
background:#66b0c4;
border: none;
}
<div class="header">
<h1>The Great <br><span id="colorDisplay">RGB</span><be>
Color Game</h1>
</div>
<div id="stripe">
<button id="reset">New Colors</button>
<span id="message"></span>
<button id="easyBtn">Easy</button>
<button id="hardBtn" class="selected">Hard</button>
</div>
I hope this can help you.
body {
background-color: #232323;
}
.header {
text-align: center;
color: white;
padding: 1.5rem;
background-color: #66b0c4;
}
.header h1 {
margin: 0;
}
.square {
width: 30%;
background: purple;
padding-bottom: 30%;
float: left;
margin: 1.66%;
}
#container {
max-width: 600px;
margin: 0 auto;
}
#stripe {
background-color: white ;
height: 30px;
text-align: center;
color: black;
padding-top: 5px;
}
.selected {
background:#66b0c4;
border: 0;
padding: 5px;
position: relative;
}
.selected::before {
position: absolute;
content: '';
top: -10px;
left: 0;
width: 100%;
background-color: #66b0c4;
height: 10px;
}
<div class="header">
<h1>The Great <br><span id="colorDisplay">RGB</span><be>
Color Game</h1>
</div>
<div id="stripe">
<button id="reset">New Colors</button>
<span id="message"></span>
<button id="easyBtn">Easy</button>
<button id="hardBtn" class="selected">Hard</button>
</div>
Solved by adjusting the height of background on the selected class. Also solved the selection issue with
*:focus {
outline: 0 !important;
}
CSS Now:
.selected {
background:#66b0c4;
border: none;
height: 30px;
}
*:focus {
outline: 0 !important;
}

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% .

Split HTML table to multi div(s)

I am having a problem with an HTML table. I want my table to appear as newspaper writing style.
Please Check Image
Desired Home Page sample
I have no idea how to jump to another div column if 50 records were filled in current div column. I am new to HTML. Thank you for reading my problem.
Current HTML :
<html>
<head>
<style>
#quotescointainer{
width: 100%;
font-size: 4px;
overflow: hidden; /* contain floated elements */
background: #fff
}
#quotesleft {
float: left;
width: 10%;
background-color: #fff;
}
#quotescenter {
float: left;
background-color: #fff;
width: 10%;
}
#quotescenter2 {
float: left;
background-color: #fff;
width: 10%;
}
#quotescenter3 {
float: left;
background-color: #fff;
width: 10%;
}
#quotescenter4 {
float: left;
background-color: #fff;
width: 10%;
}
#quotescenter5 {
float: left;
background-color: #fff;
width: 10%;
}
#quotescenter6 {
float: left;
background-color: #fff;
width: 10%;
}
#quotescenter7 {
float: left;
background-color: #fff;
width: 10%;
}
#quotescenter8 {
float: left;
background-color: #fff;
width: 10%;
}
#quotesright{
float: left;
width: 10%;
background-color: #fff;
}
</style>
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
font-size:0.7vw;
}
td, th {
border: 1px solid #000000;
text-align: left;
padding: 1px;
}
tr:nth-child(even) {
background-color: #dddddd;
}
</style>
</head>
<body>
<div id="quotescointainer">
<div id="quotesleft">
<?php echo file_get_contents("http://example.com/table?id=5452") ;?>
</div>
</div>
</body>
</html>
An easier fix for you problem would be to use the DataTables plugin. Also, it's much clearer.
You can just add something like this, with your preferences of course:
$(document).ready(function(){
$('#myTable').DataTable();
});
See link

CSS ellipsis not working when width is set to a percentage

I have the following DOM structure:
JSFiddle demo
<table class="tbl">
<tr>
<th>
<td>
<div>
<span>
A lot of text in hereeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
</span>
</div>
</td>
<td>
<div>
<span>
A lot of text in hereeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
</span>
</div>
</td>
</th>
</tr>
</table>
table.tbl{
background-color: #FFF;
border: 1px solid #000;
border-collapse: separate;
border-radius: 5px;
float: left;
margin: 10px 0;
width: 100%;
}
table.tbl tr {
font-weight: 400;
text-align: left;
}
table.tbl th {
color: #FFF;
font-weight: 400;
padding: 6px;
text-align: left;
}
table.tbl td {
padding: 10px 8px;
}
table.tbl div {
max-width: 100%;
display: inline-flex;
}
table.tbl span {
width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
This table is located on the right hand side of my page, but if there is a large amount of text in one or both of the span tags, the table extends extends off my page.
I have to keep the table at width: 100% as it needs to fill all available space on the right hand side of my page.
Can I add a CSS ellipsis to the span tag but keep the overall width of the table at width: 100%?
It doesn't seem to be working for me at the moment, any suggestions or advice would be greatly appreciated.
you can try his one:
table.tbl{
background-color: #FFF;
border: 1px solid #000;
border-collapse: separate;
border-radius: 5px;
float: left;
margin: 10px 0;
width: 100%;
table-layout: fixed;
}
table.tbl tr {
font-weight: 400;
text-align: left;
}
table.tbl th {
color: #FFF;
font-weight: 400;
padding: 6px;
text-align: left;
}
table.tbl td {
padding: 10px 8px;
}
table.tbl div {
max-width: 100%;
display: inline-flex;
}
table.tbl span {
width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
DEMO HERE