I've been reading non-stop about sizing and I still cannot seem to apply it to my code. I figured out that padding was causing my HTML table to overflow, but that it can be stopped with box-sizing: border-box;
So I added border-box to the elements I thought needed it, then to everything, trying to change width settings, but to no avail. When I remove border-box my header and navbar are affected, but the html table overflows the screen no matter what.
All my elements seem to fit on the screen perfectly fine, except the table. I assume that it is something I added that it countering the box sizing, but I commented out lines one by one and didn't find anything.
I put the full code into fiddle: https://jsfiddle.net/atpzw32L/
The CSS in question:
html, body, h1 {
margin: 0;
padding: 0;
}
html, body { min-height: 100%; }
body{
background-image: url("agaricus.png");
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
font-size: 100%;
padding: 20px;
box-sizing: border-box;
font-family: Arial, Helvetica, sans-serif;
margin: 0;
width: 100%;
}
/* Style the header */
.header {
padding: 10px;
text-align: center;
background: #832bfd7c;
color: white;
}
/* Increase the font size of the h1 element */
.header h1 {
font-size: 40px;
}
/* Style the top navigation bar */
.navbar {
overflow: hidden;
background-color: #333;
margin-bottom: 20px;
}
/* Style the navigation bar links */
.navbar a {
float: left;
display: block;
color: white;
text-align: center;
padding: 14px 20px;
text-decoration: none;
}
/* Right-aligned link */
.navbar a.right {
float: right;
}
/* Change color on hover */
.navbar a:hover {
background-color: #ddd;
color: black;
}
/* CSS to hide key columns */
th:nth-child(4), th:nth-child(5), th:nth-child(6), th:nth-child(8), th:nth-child(11), th:nth-child(12), th:nth-child(13), th:nth-child(15) {
display: none
}
td:nth-child(4), td:nth-child(5), td:nth-child(6), td:nth-child(8), td:nth-child(11), td:nth-child(12), td:nth-child(13), td:nth-child(15) {
display: none
}
/* CSS for checkboxes*/
.dropdown-check-list {
display: inline-block;
position: relative;
font-family: Verdana, sans-serif;
padding: 5px;
margin-top: 10px;
background-color: rgb(255, 255, 255);
}
.dropdown-check-list .anchor {
position: relative;
cursor: pointer;
display: inline-block;
padding: 5px 50px 5px 10px;
border: 1px solid #ccc;
min-width: 100px;
}
.dropdown-check-list .anchor:after {
position: absolute;
content: "";
border-left: 2px solid black;
border-top: 2px solid black;
padding: 5px;
right: 10px;
top: 20%;
-moz-transform: rotate(-135deg);
-ms-transform: rotate(-135deg);
-o-transform: rotate(-135deg);
-webkit-transform: rotate(-135deg);
transform: rotate(-135deg);
}
.dropdown-check-list .anchor:active:after {
right: 8px;
top: 21%;
}
.dropdown-check-list ul.items {
padding: 5px;
display: none;
margin: none;
border: 1px solid #ccc;
border-top: none;
position: absolute;
background-color: #f1f1f1;
}
.dropdown-check-list ul.items li {
list-style: none;
padding: 5px;
}
.dropdown-check-list.visible .anchor {
color: #0094ff;
}
.dropdown-check-list.visible .items {
display: block;
}
input {
float: right;
height: 18px;
width: 18px;
}
/* CSS for table */
table, th, td {
border: 2px solid;
box-sizing: border-box;
}
table {
border-collapse: collapse;
margin-top: 30px;
font-family: Verdana, sans-serif;
padding: 15px;
background-color: rgb(255, 255, 255);
}
th{
text-align: center;
height: 80px;
vertical-align: bottom;
padding: 2px;
border-bottom: 4px solid rgb(0, 0, 0);
font-size: 16px;
background-color: rgba(4, 100, 156, 0.278);
}
td {
text-align: center;
height: 100px;
width: 90%;
padding: 15px;
}
/* th{
text-align: center;
height: 100px;
vertical-align: bottom;
padding: 15px;
border-bottom: 4px solid rgb(0, 0, 0);
font-size: 16px;
background-color: rgba(4, 100, 156, 0.278);
} */
/*
td{
text-align: center;
height: 100px;
vertical-align: left;
padding: 15px;
font-size: 15px;
} */
tr:hover {background-color: rgba(4, 100, 156, 0.089);}
I aim for my end result to have all columns visible, and the table fitting within the screen, so when I add padding to the table it will fit within the screen. I would also like to keep the padding within th and td.
Please let me know how to go about this, I am out of ideas. Thank you
Concerning the width and the horizontal overflow of your table, this is simply caused by its contents: The cells (for example the header cells) contain (single) words that stretch the width of those cells (and therefore the columns) to fit into them, and so the overall width of the table becomes as wide as it is. Examples are the words "description", "information" and "identification" in the header cells.
Words won't be divided automatically, so those wordlenghts determine your minimum widths, expanding the column width and therefore the overall width of the table.
There are three methods to change that:
1.) (IMO the best) Use a smaller font size for the text. That way those longer words and with them the cells and columns won't be that wide and (maybe) fit into the screen.
2.) (also okay) Use hyphenation: Apply hyphens: auto; to td and th. The automatic hyphenation will divide words at know possible hyphenation positions.
3.) (IMO a bad solution) Apply word-break: break-word; to the cells. This will divide longer words, but at "incorrect" positions, i.e. simply at the end of the given cell width. As I wrote, not good, only to be used if nothing else works.
I would combine methods #1 and #2.
I don't know how to explain this issue. In my html web page the data is showing perfectly inside each page. When I try to print in the initial pages the data table fits inside the page but after 2,3 pages the header moves up. For more clarity I am posting the images below.
I am looping the same table with different data.
First Page
Third Page
At the end of the page it shows like this
My css code:
<style>
.verticaltext{
writing-mode: vertical-rl;
transform:scale(-1);
}
page {
background: white;
display: block;
margin: 0 auto;
/* margin-bottom: 0.5cm; */
box-shadow: 0 0 0.5cm rgba(0, 0, 0, 0.5);
}
page[size="A4"] {
width: 21cm;
height: 29.7cm;
}
page[size="A4"][layout="landscape"] {
width: 29.7cm;
height: 21cm;
}
.table-wtotbr {
width: 100%;
}
.table-wtbr {
width: 100%;
}
.table-wtotbr th, td {
border-bottom: 1px solid black;
}
.table-wtbr th, td {
border: 1px solid black;
}
.container-table {
color: black;
width: 100%;
height: 99% !important;
font-size: 11px;
/* border: 2px solid red; */
}
.footer {
position: fixed;
bottom: 0;
width: 95%;
}
.checkbox {
width: 12px;
height: 12px;
border: 1px solid #000;
display: inline-block;
}
</style>
<style type="text/css" media="print">
#media print {
html, body {
/* border: 5px solid red; */
color: black;
margin: 2px !important;
padding: 0px !important;
width: 100% !important;
height: 100vh !important;
/* overflow: hidden !important; */
font-size: 15px;
}
#page {
page-break-inside: avoid;
size: A4 landscape;
margin: 0 !important;
height: 99% !important;
}
.footer {
display: table-cell;
vertical-align: bottom;
}
.container-table {
border: 5px solid red;
overflow: hidden !important;
color: black;
width: 99% !important;
font-size: 11px;
}
}
</style>
Can anyone help me with this. Thank you in advance.
I solved the issue by adding following codes in the container div.
.container-table {
page-break-inside: avoid;
page-break-before: avoid;
page-break-after: avoid;
height: 99% !important;
padding-top:10px;
/* border: 5px solid red; */
/* overflow: hidden !important; */
color: black;
width: 99% !important;
font-size: 11px;
}
As the title says, I'd like the "background" element to fit the side of the screen (you can see it doesn't go all the way to the right), as well as to go all the way to the bottom of the screen. Can anyone help?
The code can be seen here: codepen
(specifically these elements)
```
.background {
background: url("https://static.kent.ac.uk/nexus/ems/50.jpg");
border: 3px solid black;
margin: 0 auto;
}
.text {
margin: 0 30px 0 30px;
background-color: #ffffff;
border: 1px solid black;
opacity: 0.6;
height: auto;
}
.text p {
margin: 5%;
font-weight: bold;
color: #000000;
opacity: 1;
}
```
Setting margin: -20px; on the <header> pulls it out of the page, and with that creating the horizontal scroll bar, by removing the margin: -20px; the header will be placed fully in the document and the scrollbar will disappear.
codepen
Setting margin and padding to 0, then setting background width to 100% seemed to do the trick. Is this the desired result?
* {
margin: 0px;
padding: 0px;
}
.background {
background: url("https://static.kent.ac.uk/nexus/ems/50.jpg");
border: 3px solid black;
margin: 0 auto;
width: 100%;
}
.text {
margin: 0 30px 0 30px;
background-color: #ffffff;
border: 1px solid black;
opacity: 0.6;
height: auto;
}
.text p {
margin: 5%;
font-weight: bold;
color: #000000;
opacity: 1;
}
It's happening because you gave border: 3px solid black; in your background class that's why it is not showing correctly.
If you want to use border at top and bottom then you can do like this
.background {
background: url("https://static.kent.ac.uk/nexus/ems/50.jpg");
border-top: 3px solid black;
border-bottom: 3px solid black;
margin: 0 auto;
width: 100%;
}
So the conclusion is you have to remove the border from left and right after then you can get the result you want.
Here you can see difference Codepan
Hope this will helps you
I have a tooltip and I don't know how to change color on scrollbar.
.tooltip-inner {
font-size: smaller;
white-space: pre-line;
width: 200px;
height: 200px;
overflow-y: auto;
}
you can find all infomations right there css-tricks.
But remember that IE and Firefox doesn't support it.
Example as suggested:
body::-webkit-scrollbar {
width: 1em;
}
body::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
}
body::-webkit-scrollbar-thumb {
background-color: darkgrey;
outline: 1px solid slategrey;
}
For your code try this:
.tooltip-inner::-webkit-scrollbar {
width:15px;
}
.tooltip-inner::-webkit-scrollbar-track {
background-color:#FFFFFF;
}
.tooltip-inner::-webkit-scrollbar-thumb {
background-color:#2A2A2A;
border-radius:10px;
border-style:solid;
border-width:4px;
border-color:#FFFFFF;
}
I only changed body to your class, it should work like this.
I've got a grid that I am generating on a webpage, with a some styling attached to it. The header has a background image applied to it. When the header is ONE line deep, it looks fine. The second that the header spans two lines (with a line break) it looks like the attachment. I've tried fiddling with the height but I just can't get it to take.
<style>
.Grid {background-color: #fff; margin: 5px 0 10px 0; border: solid 1px #525252; border-collapse:collapse; font-family:Calibri; color: #474747;}
.Grid td {
padding: 2px;
border: solid 1px #c1c1c1; }
.Grid th {
padding : 4px 2px;
color: #000000;
background: #363670 url(images/grid-header.png) repeat-x top;
border-left: solid 1px #525252;
font-size: 0.9em;
}
.Grid .alt {
background: #fcfcfc url(images/grid-alt.png) repeat-x top; }
.Grid .pgr {background: #363670 url(images/grid-pgr.png) repeat-x top; }
.Grid .pgr table { margin: 3px 0; }
.Grid .pgr td { border-width: 0; padding: 0 6px; border-left: solid 1px #666; font-weight: bold; color: #fff; line-height: 12px; }
.Grid .pgr a { color: Gray; text-decoration: none; }
.Grid .pgr a:hover { color: #000; text-decoration: none; }
</style>
To the .Grid th try adding
background-size: auto 100%;
The first variable is width, which we want whatever the normal behavior is because it's already working, and the second is height and is saying use 100% of available height.