How can I style the thead and tbody for this page? - html

I have an HTML page with the CSS included. The CSS works for certain parts of the page, but not the parts I discuss. I want to have a background color and make a few other style changes, but they aren't implementing.
Here is the CSS:
table.tablesorter thead tr, table.tablesorter thead tr th, table.tablesorter tfoot tr th { background-color: #e6EEEE; font-size: 8pt; padding: 4px; }
table.tablesorter thead tr .header { cursor: pointer; }
table.tablesorter tbody td { padding: 6px; vertical-align: top; border-bottom: dashed 1px #333; }
table.tablesorter tbody tr.odd td { background-color: #F0F0F6; }
table.tablesorter thead tr .headerSortUp { background-image: url(images/asc.gif) no-repeat; }
table.tablesorter thead tr .headerSortDown { background-image: url(images/desc.gif) no-repeat; }
table.tablesorter thead tr .headerSortDown, table.tablesorter thead tr .headerSortUp { background-color: #8dbdd8; }
Here is the HTML:
<table>
<thead>
<tr>
<th>Pilot ID</th>
<th>Rank</th>
<th>Total Flights</th>
<th>Total Hours</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center"><?php echo $pilotcode; ?></td>
<td align="center"><?php echo $userinfo->rank;?></td>
<?php
if($report)
{ ?>
<!--<td><strong>Latest Flight: </strong><a
href="<?php echo url('pireps/view/'.$report->pirepid); ?>">
<?php echo $report->code . $report->flightnum; ?></a>
</td>-->
<?php
}
?>
<td align="center"><?php echo $userinfo->totalflights?></td>
<td align="center"><?php echo $userinfo->totalhours; ?></td>
</tr>
</table>
All this results in is bold text with plain text below it.

Your CSS is applying the styles to a table with the class tablesorter. Simply add this to the table tag
<table class='tablesorter'>
table content
</table>
Demo

Related

How to make table fit in mobile view

I am an HTML/CSS Noob and this is my first time making a website. The issue I can not seem to figure out is how I can get my table to "fit" in mobile view. As you can see the table does cuts off at the bottom and I want to have the entire table fit in the mobile view.
Normal View
Table Mobile view
table {
font-family: 'Pathway Gothic One', sans-serif;
width: 100%;
border-collapse: collapse;
margin-bottom: 10px;
font-size: 18px;
}
td, th {
border: 1px solid black;
text-align: left;
padding: 8px;
}
tr:nth-child(even) {
background-color: lightgray;
}
#media screen and (max-width: 767px) {
.left2, .main2 {
width: 100%;
}
thead {
display: none;
}
td {
display: block;
}
td:first-child {
background-color: black;
color: white;
}
td:nth-child(1)::before {
content: "Repair Type"
}
td {
text-align: center;
}
td::before {
float: left;
}
}
<table>
<thead>
<tr>
<th>Repair Type</th>
<th>Price</th>
<th>Turnaround Time</th>
</thead>
<tbody>
<tr>
<td>Battery Replacement</td>
<td>$50 - $100</td>
<td>Same Day</td>
</tr>
<tr>
<td>Camera Replacement</td>
<td>$30 - $105</td>
<td>Same Day</td>
</tr>
<tr>
<td>Charging Port Repair</td>
<td>$25 - $100</td>
<td>Same Day</td>
</tr>
<tr>
<td>Diagnostic</td>
<td>Free</td>
<td>Same Day</td>
</tr>
<tr>
<td>Ear Piece Replacement</td>
<td>$80</td>
<td>Same Day</td>
</tr>
<tr>
<td>Home Button Replacement - Select Models Only</td>
<td>$50 - $150</td>
<td>Same Day</td>
</tr>
<tr>
<td>Screen Repair</td>
<td>$30 - $150</td>
<td>Same Day</td>
</tr>
<tr>
<td>Water Damage Repair</td>
<td>$50 - $150</td>
<td>Same Day</td>
</tr>
<tr>
<td>Virus Removal</td>
<td>$80</td>
<td>Same Day</td>
</tr>
</tbody>
</table>
you can use the #media query for the table
.table-responsive {
min-height: .01%;
overflow-x: auto;
}
#media screen and (max-width: 767px) {
.table-responsive {
width: 100%;
margin-bottom: 15px;
overflow-y: hidden;
-ms-overflow-style: -ms-autohiding-scrollbar;
border: 1px solid #ddd;
}
.table-responsive > .table {
margin-bottom: 0;
}
.table-responsive > .table > thead > tr > th,
.table-responsive > .table > tbody > tr > th,
.table-responsive > .table > tfoot > tr > th,
.table-responsive > .table > thead > tr > td,
.table-responsive > .table > tbody > tr > td,
.table-responsive > .table > tfoot > tr > td {
white-space: nowrap;
}
}
what it does is that it looks for the display size and once a certain size is reached it triggers the CSS relative to that screen size, this is completely user-defined and you can modify it however you want

Making the html table responsive without using jQuery or Javascript

How to we make the HTML table to responsive without using bootstrap or JQuery, it has more than eight-column.
I'm Using Percentage for each column even its not coming responsive when we increase the text
Scroll coming at the bottom. how to avoid scroll, I don't want to use the Unorder list or div elements
body{
font-family: arial, sans-serif;
font-size:12px
}
.text-to-right {
text-align: right;
}
.text-to-left {
text-align: left;
padding-left: 1rem;
}
table {
width: 100%;
border-left: 1px solid #f3f1f1;
border-bottom: 1px solid #f3f1f1fa;
border-spacing: 0;
}
.table-bordered > tbody > tr > td,
.table-bordered > tbody > tr > th,
.table-bordered > tfoot > tr > td,
.table-bordered > tfoot > tr > th,
.table-bordered > thead > tr > td,
.table-bordered > thead > tr > th {
border-left: 1px solid #f3f1f1;
border-bottom: 1px solid #d2cecefa;
/*box-shadow: 0 2px 4px 0 rgba(241, 230, 230, 0.16), 0 2px 10px 0 rgba(247, 245, 245, 0.12);*/
box-shadow: 0 1px 1px 0 #f3f1f1,0 1px 1px 0 #f3f1f1;
}
.table-bordered > tbody > tr > td:first-child,
.table-bordered > tbody > tr > th:first-child,
.table-bordered > tfoot > tr > td:first-child,
.table-bordered > tfoot > tr > th:first-child,
.table-bordered > thead > tr > td:first-child,
.table-bordered > thead > tr > th:first-child {
border-left-width: 0;
}
.table-bordered tbody tr td:last-child,.table-bordered thead tr th:last-child {
border-right: 1px solid #f3f1f1;;
}
.table-bordered > thead > th:last-child {
border-right: 1px solid #f3f1f1;
}
th {
padding: 1rem 0;
background: #192b4b;
color: #fff;
font-size: 1.3rem;
font-weight: normal;
border-left: 1px solid #f3f1f1;
}
td {
padding: 1rem;
text-transform: capitalize;
color: #6b5e5e;
}
.table-bright-data {
color: #007dc5;
font-size: 1.8rem;
font-family: 'Roboto Condensed', Arial, sans-serif;
}
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<table class="table-bordered">
<thead>
<tr>
<th width="05%">
S.No
</th>
<th class="text-to-left" width="23%">Name</th>
<th width="10%">Code</th>
<th width="12%">Type</th>
<th width="10%"> Profile</th>
<th width="13%">Time</th>
<th width="10%">Size</th>
<th width="11%">Date</th>
</tr>
</thead>
<tbody>
<tr>
<td class="align-center">
1
</td>
<td class="text-to-left table-bright-data">Responsive layout</td>
<td class="text-to-left">LDHSNSJ734674</td>
<td class="text-to-left">Fixed Interest </td>
<td class="text-to-left">high </td>
<td class="text-to-right">No minimum </td>
<td class="text-to-right">0 </td>
<td class="text-to-right">05-Dec-2001 </td>
</tr>
<tr>
<td class="align-center">
2
</td>
<td class="text-to-left table-bright-data">Responsive layout</td>
<td class="text-to-left">DHEYE933</td>
<td class="text-to-left">Responsive layout </td>
<td class="text-to-left"> </td>
<td class="text-to-right">No minimum </td>
<td class="text-to-right">0 </td>
<td class="text-to-right">05-Dec-2001 </td>
</tr>
</tbody>
</table>
</body>
</html>
You could collapse a table like this
CSS
#media (max-width: 1024px) {
.collapse {
display: block;
}}
HTML
<td class="collapse">
Content
</td>
<td class="collapse">
Content
</td>
I would add multiple classes with different #media (max-width: xxx) so they don't collapse all at once. How you want to collapse them, and in what order you should figur out yourself.
You can look over here https://css-tricks.com/responsive-data-tables/ if you got any more questions.
Personally I like using div over tables, e.g: http://www.responsivegridsystem.com/

background-image isn't applying fully

I want that my background-image applies fully to the table borders, but it doesn't really work, it only applies to the center of the table borders.
It doesn't work without
border-collapse: separate;
So I don't know what else to do.
Yes, im a CSS and HTML beginner.
tbody {
color: black;
}
th {
color: black;
}
h1 {
color: black;
}
.table, .table-bordered{
border-spacing: 4px;
border-collapse: separate;
background-image: url('http://fs5.directupload.net/images/170604/sahdx5gv.png');
background-size: 100% auto;
background-repeat: repeat;
}
.table > thead > tr > th,
.table > tbody > tr > th,
.table > tfoot > tr > th,
.table > thead > tr > td,
.table > tbody > tr > td,
.table > tfoot > tr > td {
border: none;
background-color: #fff;
}
Heres my HTML CODE:
<!DOCTYPE html>
<!-- Latest compiled and minified CSS -->
<head>
<link rel="stylesheet" href="shitfuck.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<div class="container">
<h1 class="text-center">OpSec Leaderboard</h1>
<table class="table table-bordered"></br>
<thead>
<tr>
<th>Place</th>
<th>Username</th>
<th>Rank</th>
<th>Points</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>username</td>
<td>rank</td>
<td>1337</td>
</tr>
<tr>
<td>2</td>
<td>username</td>
<td>rank</td>
<td>1337</td>
</tr>
<tr>
<td>3</td>
<td>username</td>
<td>rank</td>
<td>1337</td>
</tr>
</tbody>
</table>
</div>
</div>
You just want a solid background, so remove the background image properties and just use background-color: blue; or background: blue; for short.
tbody {
color: black;
}
th {
color: black;
}
h1 {
color: black;
}
.table, .table-bordered{
border-spacing: 4px;
border-collapse: separate;
/*
background-image: url('http://fs5.directupload.net/images/170604/sahdx5gv.png');
background-size: cover;
background-repeat: repeat;
background-position: center center;
*/
background: blue;
}
.table > thead > tr > th,
.table > tbody > tr > th,
.table > tfoot > tr > th,
.table > thead > tr > td,
.table > tbody > tr > td,
.table > tfoot > tr > td {
border: none;
background-color: #fff;
}
Heres my HTML CODE:
<!DOCTYPE html>
<!-- Latest compiled and minified CSS -->
<head>
<link rel="stylesheet" href="shitfuck.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<div class="container">
<h1 class="text-center">OpSec Leaderboard</h1>
<table class="table table-bordered"></br>
<thead>
<tr>
<th>Place</th>
<th>Username</th>
<th>Rank</th>
<th>Points</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>username</td>
<td>rank</td>
<td>1337</td>
</tr>
<tr>
<td>2</td>
<td>username</td>
<td>rank</td>
<td>1337</td>
</tr>
<tr>
<td>3</td>
<td>username</td>
<td>rank</td>
<td>1337</td>
</tr>
</tbody>
</table>
</div>
</div>

Firefox table cell width completly different than Chrome's

I have a problem with my table cell width. On Chrome it works perfectly, but on Firefox it looks a lot different and I don't whats causing it.
This is the chrome one, looking perfect:
This is the Firefox one, being squeezed tight:
Any idea why this is? Heres my code.
/* Latest games */
.lp-latestgames {
height: 466px;
}
.lp-latestgames .title {
margin-left: 460px;
margin-top: 56px;
margin-bottom: 21px;
}
.lp-latestgames .table {
margin-bottom: 0;
}
.lp-latestgames .table thead {
background-color: rgba(0, 0, 0, 0.45);
}
.lp-latestgames .table thead th {
font-size: 16px;
font-weight: 500 !important;
color: white;
height: 49px;
vertical-align: middle;
}
.lp-latestgames .table thead > tr > th { border-bottom: none; }
.lp-latestgames .table tbody > tr > td {
height: 81px;
border-top: 2px solid #111316;
background-color: rgba(0, 0, 0, 0.19);
vertical-align: middle;
font-size: 14px;
font-weight: 500;
color: white;
}
.lp-latestgames .table tbody > tr:first-child > td { border-top: none; }
.lp-latestgames .table tbody > tr > td:first-child,
.lp-latestgames .table thead > tr > th:first-child{
/* ÜBERARBEITEN!!!!! */
padding-left: 460px;
max-width: 200px;
}
.lp-latestgames .table tbody > tr > td:last-child,
.lp-latestgames .table thead > tr > th:last-child{
/* ÜBERARBEITEN!!!!! */
padding-right: 460px;
max-width: 200px;
}
.lp-latestgames .table tbody > tr > td > .gd-c-versus {
display: block;
font-weight: normal;
font-family: Arial;
color: #494949;
}
.lp-latestgames .table thead > tr > th:nth-child(4),
.lp-latestgames .table thead > tr > th:nth-child(5),
.lp-latestgames .table tbody > tr > td:nth-child(4),
.lp-latestgames .table tbody > tr > td:nth-child(5) {
text-align: center;
}
<div class="lp-latestgames">
<!-- Games -->
<table class="table">
<thead>
<tr>
<th>Name <img src="img/gd_content_arrow_dn.png"></th>
<th>Price Pool <img src="img/gd_content_arrow_dn.png"></th>
<th>Entry <img src="img/gd_content_arrow_dn.png"></th>
<th>Avg Skill <img src="img/gd_content_arrow_dn.png"></th>
<th>Time Remaining <img src="img/gd_content_arrow_up.png"></th>
</tr>
</thead>
<tbody>
<tr>
<td>Im bored. Fite me<span class="gd-c-versus">1 vs 1</span></td>
<td><img src="img/gd_content_coin.png"> 20</td>
<td><img src="img/gd_content_coin.png"> 10</td>
<td><input type="text" value="730" class="circle"></td>
<td>00:00:32</td>
</tr>
<tr>
<td>EG vs LGD - Wild Cards Entry<span class="gd-c-versus">5 vs 5</span></td>
<td><img src="img/gd_content_coin.png"> 1.500.000</td>
<td><img src="img/gd_content_coin.png"> 20</td>
<td><input type="text" value="980" class="circle"></td>
<td>00:01:47</td>
</tr>
<tr>
<td>cyka blyat<span class="gd-c-versus">5 vs 5</span></td>
<td><img src="img/gd_content_coin.png"> 20</td>
<td><img src="img/gd_content_coin.png"> 10</td>
<td><input type="text" value="730" class="circle"></td>
<td>00:02:4</td>
</tr>
</tbody>
</table>
</div>
Have you declared <!DOCTYPE> in your html page, if not give it a try. This doctype is an instruction to the web browser about what version of HTML the page is written in.
Try adding this:
.table { table-layout: fixed }
See snippet
See POST
/* Latest games */
.lp-latestgames {
height: 466px;
}
.lp-latestgames .title {
margin-left: 460px;
margin-top: 56px;
margin-bottom: 21px;
}
.lp-latestgames .table {
margin-bottom: 0;
table-layout: fixed; /*<<<===== ADD THIS RULE RIGHT HERE */
}
.lp-latestgames .table thead {
background-color: rgba(0, 0, 0, 0.45);
}
.lp-latestgames .table thead th {
font-size: 16px;
font-weight: 500 !important;
color: white;
height: 49px;
vertical-align: middle;
}
.lp-latestgames .table thead > tr > th {
border-bottom: none;
}
.lp-latestgames .table tbody > tr > td {
height: 81px;
border-top: 2px solid #111316;
background-color: rgba(0, 0, 0, 0.19);
vertical-align: middle;
font-size: 14px;
font-weight: 500;
color: white;
}
.lp-latestgames .table tbody > tr:first-child > td {
border-top: none;
}
.lp-latestgames .table tbody > tr > td:first-child,
.lp-latestgames .table thead > tr > th:first-child {
/* ÜBERARBEITEN!!!!! */
padding-left: 460px;
max-width: 200px;
}
.lp-latestgames .table tbody > tr > td:last-child,
.lp-latestgames .table thead > tr > th:last-child {
/* ÜBERARBEITEN!!!!! */
padding-right: 460px;
max-width: 200px;
}
.lp-latestgames .table tbody > tr > td > .gd-c-versus {
display: block;
font-weight: normal;
font-family: Arial;
color: #494949;
}
.lp-latestgames .table thead > tr > th:nth-child(4),
.lp-latestgames .table thead > tr > th:nth-child(5),
.lp-latestgames .table tbody > tr > td:nth-child(4),
.lp-latestgames .table tbody > tr > td:nth-child(5) {
text-align: center;
}
<div class="lp-latestgames">
<!-- Games -->
<table class="table">
<thead>
<tr>
<th>Name
<img src="img/gd_content_arrow_dn.png">
</th>
<th>Price Pool
<img src="img/gd_content_arrow_dn.png">
</th>
<th>Entry
<img src="img/gd_content_arrow_dn.png">
</th>
<th>Avg Skill
<img src="img/gd_content_arrow_dn.png">
</th>
<th>Time Remaining
<img src="img/gd_content_arrow_up.png">
</th>
</tr>
</thead>
<tbody>
<tr>
<td>Im bored. Fite me<span class="gd-c-versus">1 vs 1</span>
</td>
<td>
<img src="img/gd_content_coin.png">20</td>
<td>
<img src="img/gd_content_coin.png">10</td>
<td>
<input type="text" value="730" class="circle">
</td>
<td>00:00:32</td>
</tr>
<tr>
<td>EG vs LGD - Wild Cards Entry<span class="gd-c-versus">5 vs 5</span>
</td>
<td>
<img src="img/gd_content_coin.png">1.500.000</td>
<td>
<img src="img/gd_content_coin.png">20</td>
<td>
<input type="text" value="980" class="circle">
</td>
<td>00:01:47</td>
</tr>
<tr>
<td>cyka blyat<span class="gd-c-versus">5 vs 5</span>
</td>
<td>
<img src="img/gd_content_coin.png">20</td>
<td>
<img src="img/gd_content_coin.png">10</td>
<td>
<input type="text" value="730" class="circle">
</td>
<td>00:02:4</td>
</tr>
</tbody>
</table>
</div>
Try to set th or td width using rem instead of px
Each rem equals 16px

Can't :hover whole line of a table

When I pass mouse over a cell of the table, I want to highlight the whole line! But with the code that I have all I can to highlight just one cell! This is my table:
<table id="myTable" class="tablesorter">
<thead>
<tr>
<th>Title1</th>
<th>Title2</th>
<th>Title3</th>
</tr>
</thead>
<tbody>
<tr>
<td>Bach</td>
<td>42526</td>
<td>Dec 10, 2002 5:14 AM</td>
</tr>
<tr>
<td>Doe</td>
<td>243155</td>
<td>Jan 18, 2007 9:12 AM</td>
</tr>
<tr>
<td>Conway</td>
<td>35263</td>
<td>Jan 18, 2001 9:12 AM</td>
</tr>
</tbody>
</table>
and css is
/*Table sort*/
table.tablesorter {
font-family:arial;
background-color: #e6EEEE;
font-size: 8pt;
width: 100%;
text-align: left;
}
table.tablesorter thead tr th, table.tablesorter tfoot tr th {
background-color: #e6EEEE;
border: 1px solid #FFF;
font-size: 8pt;
padding: 4px;
}
table.tablesorter thead tr .header {
background-repeat: no-repeat;
background-position: center right;
cursor: pointer;
}
table.tablesorter tbody td {
color: #3D3D3D;
padding: 4px;
background-color: #FFF;
vertical-align: top;
}
table.tablesorter tbody tr.odd td {
background-color:#F0F0F6;
}
table.tablesorter thead tr .headerSortUp {
}
table.tablesorter thead tr .headerSortDown {
}
table.tablesorter thead tr .headerSortDown, table.tablesorter thead tr .headerSortUp {
/*background-color: #8dbdd8;*/
background-color: #e6EEEE;
}
table.tablesorter tbody tr :hover {
background: #8dbdd8;
}
What is missing in my CSS to highlight whole line?
You simply need to remove a space in your selector:
table.tablesorter tbody tr:hover
/* ^ space was removed */
Because you left a comment saying "it's not working":
See here, where it works: http://jsfiddle.net/thirtydot/Pe6Xe/
Per your edit, this will work:
table.tablesorter tbody tr:hover td {
background: #8dbdd8;
}
The issue was that the background-color on your tds was covering the changed background-color on the tr hover.
See: http://jsfiddle.net/thirtydot/Pe6Xe/1/
You need to remove the space between tr and :hover. As in, change this:
tr :hover
to:
tr:hover