I want to fix the tfoot to the bottom of the page with it being as responsive as the rows of the table.
My code: https://codepen.io/adu8/pen/MWWXqGY
The problem I face now is once I add the class="fixed-bottom" to the tr of tfoot, it goes to bottom and gets misaligned.
I tried fixing it with having a workaround by adding this css:
tfoot td {
display: inline-block;
width: calc((100%/8) - 10px);
}
As in this codepen: https://codepen.io/adu8/pen/dyyKqOv. However, it's still not able to be as responsive.
I would appreciate if someone helps fixing this.
Please use this CSS
body {
background-color: midnightblue;
color: white;
}
table {
max-width: 100%;
font-size: 2vw;
}
thead, tr, tfoot {
text-align: center;
background-color: midnightblue;
}
.table-striped>tbody>tr:nth-child(odd)>td,
.table-striped>tbody>tr:nth-child(odd)>th {
background-color: darkslateblue;
}
.table-hover tbody tr:hover > th {
/*background-color: #06765d;*/
background-color: #009999;
}
.table td {
padding: 0.05rem;
margin: 0px;
}
.fixed-bottom {
width: 100%;
}
table tr {
display: flex; display: -webkit-flex;
width: 100%;
}
tr th,
tr td {
width: calc(100% / 8);
}
tr th:first-child,
tr td:first-child {
width: 22%;
flex-shrink: 0;
-webkit-flex-shrink: 0;
}
Related
I need some help in a sizing question. If you view the following code in desktop browsers, everything is sized as it should be. If you try to open it on a mobile phone (I have tested it with several iPhones), the td (white with grey border) is not resized properly. The td element is resized correct, if there is a span element that's causing the overflow.
div.highlighter-rouge {
overflow-x: scroll;
}
div.highlight {
width: 100%;
}
.highlight {
display: inline-block;
}
.highlight {
background-color: #eeeeee;
}
pre.highlight {
margin-top: 0;
margin-bottom: 0;
}
pre code {
white-space: pre;
}
table {
margin: 15px 0;
padding: 0;
}
table {
word-wrap: anywhere;
}
table tr {
border-top: 1px solid #cccccc;
background-color: white;
margin: 0;
padding: 0;
}
table tr td {
border: 1px solid #cccccc;
text-align: left;
margin: 0;
padding: 6px 13px;
}
table tr th :last-child,
table tr td :last-child {
margin-bottom: 0;
}
table tr th :first-child,
table tr td :first-child {
margin-top: 0;
}
td.rouge-code>pre>span {
display: inline-block;
}
.highlight .nt {
color: #000080;
}
.highlight .s1 {
color: #d01040;
}
html {
-webkit-text-size-adjust: 100%;
}
<div class="language-bash highlighter-rouge">
<div class="highlight">
<pre class="highlight"><code><table class="rouge-table"><tbody><tr><td class="rouge-gutter gl"><pre class="lineno">1
2</pre>
</td>
<td class="rouge-code">
<pre>ausearch <span class="nt">-c</span> <span class="s1">'ajp-bio-0:0:0:0'</span> <span class="nt">--raw</span> | audit2allow <span class="nt">-M</span> my-ajpbio0000
semodule <span class="nt">-i</span> my-ajpbio0000.pp</pre>
</td>
</tr>
</tbody>
</table</code>
</pre>
</div>
</div>
I've tried many things now, but my level of knowledge about this, just leads to trial and error. If you don't really like the solution with tables, I can also create a version with the exact same behaviour without them.
https://codepen.io/ribbonCaptain/pen/GRrqgpE
.rouge-table td {
vertical-align: top;
}
.rouge-table td pre {
white-space: pre-wrap;
}
...will do it. See it here.
There's not much to explain.
I have a table where I fixed the columns and the font to the text. The table is optimized by bootstrap.
I try to print the table through the print menu of the browser and it does not respect the style from css the table that is generated on the sheet
Code for js:
function myFunction() {
var css = '#page { size: landscape;} }',
head = document.head || document.getElementsByTagName('head')[0],
style = document.createElement('style');
style.type = 'text/css';
style.media = 'print';
if (style.styleSheet){
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
head.appendChild(style);
window.print();
}
myFunction();
Code css:
#media print;
.table th:nth-child(1),
.table td:nth-child(1) {
width: 5px;
}
.table th:nth-child(2),
.table td:nth-child(2) {
width: 5px;
}
.table th:nth-child(3),
.table td:nth-child(3) {
width: 5px;
}
.table th:nth-child(4),
.table td:nth-child(4) {
width: 5px;
}
.table th:nth-child(5),
.table td:nth-child(5) {
width: 5px;
}
.table th:nth-child(6),
.table td:nth-child(6) {
width: 5px;
}
.table th:nth-child(7),
.table td:nth-child(7) {
width: 5px;
}
.table th:nth-child(8),
.table td:nth-child(8) {
width: 5px;
}
.table th:nth-child(9),
.table td:nth-child(9) {
width: 5px;
}
.table th:nth-child(10),
.table td:nth-child(10) {
width: 5px;
}
.table th:nth-child(11),
.table td:nth-child(11) {
width: 5px;
}
.table th:nth-child(12),
.table td:nth-child(12) {
font-size: 20px;
width: 120px;
}
.table th:nth-child(13),
.table td:nth-child(13) {
font-size: 10px;
width: 5px;
}
.table th:nth-child(14),
.table td:nth-child(14) {
font-size: 10px;
width: 5px;
}
.table th:nth-child(15),
.table td:nth-child(15) {
font-size: 10px;
width: 5px;
}
.table th:nth-child(16),
.table td:nth-child(16) {
font-size: 10px;
width: 5px;
}
I would like to respect the css style as in the html page and to generate the same thing on the sheet, thank you!
The browser (by default) never prints the background color. You would need to enable that option in your browser.
If you are using a print-specific stylesheet, make sure it includes media="screen, print":
<link rel="stylesheet" type="text/css" href="print.css" media="screen, print" />
Also, remember to enable the printing settings in your browser:
-webkit-print-color-adjust: exact;
I'm building a website in wordpress, using the 'Rookie' theme, and have installed the sportpress plugin, as well as an accordion plugin.
I'd like to display a table in accordions, but also make it display properly when on a mobile device. This is the webpage > http://wnu.054.myftpupload.com/fixtures-and-results/
I've sorted this for the majority of tables (fixtures for the month) using the following CSS:
.table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
tr:nth-child(even) {
background-color: #dddddd;
}
#media only screen and (max-width: 40em) {
thead th {
display: none;
}
td, th {
display: block;
}
td[data-th]:before {
content: attr(data-th);
}
}
table {
border-spacing: 0;
}
td,
th {
padding: 0.5em;
}
th {
font-weight: bold;
text-align: left;
}
thead th {
background-color: #999;
color: white;
}
td > div {
float: right;
}
#media screen and (max-width: 500px) {
thead th {
display: none;
}
thead th:first-child:after {
content: "'s";
}
td, th {
display: block;
width: 100% !important;
}
td[data-th]:before {
content: attr(data-th);
border-radius: 10px 0px 0px 10px;
font-weight: bold;
min-width: 10rem;
display: inline-block;
}
The problem I've got is that I don't have access to edit the tables in Sportspress so I can't edit the table data on the Player stats table so that it includes the 'data-th="heading"' - meaning the headers don't display.
Without the CSS above, the sportspress table displays OK (not perfect, but not bad either), I was wondering if I can set it so that the sportspress table ignores the CSS I've set up (on the responsive view) or if there is a better way to do this? If possible, the sportpress table would display the headers, but I think I'd have to upgrade from the free version?
I am working in Angular Project but stuck in a design Issue
I am want to scroll the body of the table making body header fixed
I tried to do the at but not able to scroll just table body
My code and design is ready I have put it in below link -
https://stackblitz.com/edit/angular-x8c89j?file=src%2Fapp%2Fapp.component.html
Please update your table style as below
table {
width: 100%;
}
table, td {
border-collapse: collapse;
border: 1px solid #000;
}
thead {
display: table;
width: calc(100% - 17px);
}
tbody {
display: block;
max-height: 200px;
overflow-y: scroll;
}
th, td {
padding: 5px;
word-break: break-all;
}
tr {
display: table;
width: 100%;
box-sizing: border-box;
}
td {
text-align: center;
border-bottom: none;
border-left: none;
}
tr th:first-child,
tr td:first-child {
width: 100px;
}
I am having trouble getting the text centered in the middle of the cell, the single lines are fine but the double lines do not get in the center of the cell :
I have a simpler version on JSfiddle of my code but with all the css that I use.
When I remove the plan-list-view-table class (for the FIXED header) the vertical align works, but I cant get around the display:block without breaking the fixed header.
The code that is breaking the vertical align in particular:
#plan-list-view-table tr:after { /* clearing float */
content: ' ';
display: block;
clear: both;
}
You can use flexbox properties on the td
#plan-list-view-table thead,
#plan-list-view-table tbody,
#plan-list-view-table tfoot,
#plan-list-view-table tr,
#plan-list-view-table th,
#plan-list-view-table td {
display: block;
}
#plan-list-view-table thead tr,
#plan-list-view-table tfoot tr {
/* fallback */
width: 97%;
/* minus scroll bar width */
width: -webkit-calc(100% - 16px);
width: -moz-calc(100% - 16px);
width: calc(100% - 16px);
}
#plan-list-view-table tr:after {
/* clearing float */
content: ' ';
display: block;
/*visibility: hidden;*/
clear: both;
}
.table-responsive>.table>tbody>tr>td {
vertical-align: middle;
}
#plan-list-view-table tbody {
height: 65vh;
}
#plan-list-view-table tbody td,
#plan-list-view-table thead th,
#plan-list-view-table tfoot td {
width: 16.70%;
float: left;
}
#plan-list-view-table tbody td {
/* height: 50px; */
}
#plan-list-view-table thead th {
height: 35px;
}
/* Every odd column has a light grey color */
#table-body tr {
background-color: rgba(224, 224, 224, 0.3);
}
/* Hover on plan entry */
#table-body tr:hover {
background-color: rgba(233, 233, 234, 1);
cursor: pointer;
}
/* Green checkbox for "Published" column */
#table-body tr td.green {
color: green;
}
/* Red checkbox for "Published" column (Not working)*/
#table-body tr td.fade {
color: red;
}
/* Right delimiter between plans in the plan list*/
#table-head-data tr th,
#table-body tr td {
border-right: thin solid rgb(224, 224, 224);
background: transparent;
vertical-align: middle;
}
.table-responsive>.table>tbody>tr>td {
vertical-align: middle;
}
.table-responsive {
overflow: auto;
/*margin-bottom:20px;*/
}
.table {
border-left: 0px;
width: 100%;
table-layout: fixed;
text-align: center;
font-family: 'Lato', sans-serif;
}
.planListItem td {
display: flex !important;
justify-content: center;
align-items: center;
height: 50px;
}
<div class="table-responsive" id="table-res">
<table class="table" id="plan-list-view-table">
<thead id="table-head-data">
<tr>
<th> Name <span class="glyphicon"></span></th>
<th> Description <span class="glyphicon"></span></th>
<th> Start <span class="glyphicon"></span></th>
<th> End <span class="glyphicon"></span></th>
<th> Published Date <span class="glyphicon"></span></th>
</tr>
</thead>
<tbody id="table-body" #plantable>
<tr class="planListItem">
<td style="overflow: hidden;">Test</td>
<td style="overflow: hidden;">TestDoubleLine TestDoubleLine TestDoubleLine</td>
<td style="overflow: hidden;">3 TestDoubleLine oubleLine</td>
<td style="overflow: hidden;">4</td>
<td style="overflow: hidden;">5</td>
</tr>
</tbody>
</table>
</div>
not sure of all side effects but these are working (note commented-out css):
#plan-list-view-table tbody {
/* height: 65vh; */
}
#plan-list-view-table thead, #plan-list-view-table tbody,
#plan-list-view-table tfoot, #plan-list-view-table tr,
#plan-list-view-table th, #plan-list-view-table td {
/* display: block; */
}
#plan-list-view-table tbody td, #plan-list-view-table thead th,
#plan-list-view-table tfoot td {
/* float: left; */
width: 16.7%;
}