Collapse an element when expand another element only css - html

I have asp.net site. By some reason, I can't use javascript in my code. I use this code for create a expansible table:
html, body, form {
margin: 0 auto;
padding: 0;
text-align: left;
height: 100%;
top: 0;
bottom: 0;
overflow: hidden;
}
tr:nth-child(even) {
background: #F5F5F5;
}
tr:nth-child(odd) {
background: #DCDCDC;
}
tr:hover
{
background-color: #D3D3D3;
}
.toggle-box {
display: none;
}
.toggle-box + label {
cursor: pointer;
display: block;
font-weight: bold;
line-height: 25px;
margin-bottom: 2px;
margin-left: 5px;
background-color: #F1F8FF;
border-bottom: 1px solid gray;
}
.toggle-box + label:hover {
background-color: #C5ECFF;
}
.toggle-box + label + div {
display: none;
margin-bottom: 10px;
margin-left: 20px;
}
.toggle-box:checked + label + div {
display: block;
}
.toggle-box + label:before {
background-color: #66AEFF;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;
color: #FFFFFF;
content: "+";
display: block;
float: left;
font-weight: bold;
height: 25px;
line-height: 25px;
margin-right: 5px;
text-align: center;
width: 25px;
}
.toggle-box:checked + label:before {
content: "\2212";
}
#matru {
border: 0;
text-align: left;
position: absolute;
top: 100px;
left: 300px;
}
<div runat="server" id="sidebar" style="padding: 5px 0 0 5px;">
<input class='toggle-box' id='header1' type='checkbox' /><label for='header1'>Nguyễn Văn Tư</label><div>
<table style='text-align: left; width: 100%; vertical-align: middle;'>
<tr>
<td>Tên khách hàng</td>
<td>Nguyễn Văn Tư</td>
</tr>
<tr>
<td>Mã khách hàng</td>
<td>PC06LL0191387</td>
</tr>
<tr>
<td>Sery công tơ</td>
<td>14138734</td>
</tr>
<tr>
<td>Chỉ số cũ</td>
<td>194.000</td>
</tr>
<tr>
<td>Chỉ số mới</td>
<td>196.60</td>
</tr>
<tr>
<td>Sản lượng mới</td>
<td>2</td>
</tr>
</table>
</div>
<input class='toggle-box' id='header2' type='checkbox' /><label for='header2'>ĐInh Thị Tha</label><div>
<table style='text-align: left; width: 100%; vertical-align: middle;'>
<tr>
<td>Tên khách hàng</td>
<td>ĐInh Thị Tha</td>
</tr>
<tr>
<td>Mã khách hàng</td>
<td>PC06LL0182038</td>
</tr>
<tr>
<td>Sery công tơ</td>
<td>14140069</td>
</tr>
<tr>
<td>Chỉ số cũ</td>
<td>2050.000</td>
</tr>
<tr>
<td>Chỉ số mới</td>
<td>2104.10</td>
</tr>
<tr>
<td>Sản lượng mới</td>
<td>54</td>
</tr>
</table>
</div>
<input class='toggle-box' id='header3' type='checkbox' /><label for='header3'>Nguyễn Văn Nhựt</label><div>
<table style='text-align: left; width: 100%; vertical-align: middle;'>
<tr>
<td>Tên khách hàng</td>
<td>Nguyễn Văn Nhựt</td>
</tr>
<tr>
<td>Mã khách hàng</td>
<td>PC06LL0190775</td>
</tr>
<tr>
<td>Sery công tơ</td>
<td>14138746</td>
</tr>
<tr>
<td>Chỉ số cũ</td>
<td>2699.000</td>
</tr>
<tr>
<td>Chỉ số mới</td>
<td>2785.10</td>
</tr>
<tr>
<td>Sản lượng mới</td>
<td>86</td>
</tr>
</table>
</div>
<input class='toggle-box' id='header4' type='checkbox' /><label for='header4'>Mai Văn Lý</label><div>
<table style='text-align: left; width: 100%; vertical-align: middle;'>
<tr>
<td>Tên khách hàng</td>
<td>Mai Văn Lý</td>
</tr>
<tr>
<td>Mã khách hàng</td>
<td>PC06LL0182035</td>
</tr>
<tr>
<td>Sery công tơ</td>
<td>14138744</td>
</tr>
<tr>
<td>Chỉ số cũ</td>
<td>2581.000</td>
</tr>
<tr>
<td>Chỉ số mới</td>
<td>2631.70</td>
</tr>
<tr>
<td>Sản lượng mới</td>
<td>50</td>
</tr>
</table>
</div>
</div>
Full code here: https://jsfiddle.net/pdhung197/3eomjp3m/
But I want more: When I click on an collapsed element, that element will be expanded and other element will be collapsed.
This project can use only CSS, no JavaScript so I have no solution to do it.

The trick is simple. Just replace the input from checkbox to radio and add attribute name with same value in all of the inputs.
This changes mean that there is just one input that can be checked in the same time. So, if you click to one item all the rest will be closed.
html, body, form {
margin: 0 auto;
padding: 0;
text-align: left;
height: 100%;
top: 0;
bottom: 0;
overflow: hidden;
}
tr:nth-child(even) {
background: #F5F5F5;
}
tr:nth-child(odd) {
background: #DCDCDC;
}
tr:hover
{
background-color: #D3D3D3;
}
.toggle-box {
display: none;
}
[type="reset"] {
border: 0;
width: 100%;
text-align: inherit;
padding: 0;
font: inherit;
margin: 0;
outline:0 !important;
}
.toggle-box + label,
[type="reset"]{
cursor: pointer;
display: block;
font-weight: bold;
line-height: 25px;
margin-bottom: 2px;
margin-left: 5px;
background-color: #F1F8FF;
border-bottom: 1px solid gray;
}
.toggle-box + label:hover {
background-color: #C5ECFF;
}
.toggle-box + label + button {
display:none;
}
.toggle-box:checked + label {
display:none;
}
.toggle-box:checked + label + button {
display:block;
}
.toggle-box + label + button + div {
display: none;
margin-bottom: 10px;
margin-left: 20px;
}
.toggle-box:checked + label + button + div {
display: block;
}
.toggle-box + label:before,
[type="reset"]:before{
background-color: #66AEFF;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;
color: #FFFFFF;
content: "+";
display: block;
float: left;
font-weight: bold;
height: 25px;
line-height: 25px;
margin-right: 5px;
text-align: center;
width: 25px;
}
.toggle-box:checked + label:before {
content: "\2212";
}
#matru {
border: 0;
text-align: left;
position: absolute;
top: 100px;
left: 300px;
}
<form>
<div runat="server" id="sidebar" style="padding: 5px 0 0 5px;">
<input class='toggle-box' id='header1' type="radio" name="radio" /><label for='header1'>Nguyễn Văn Tư</label>
<button type="reset">Nguyễn Văn Tư</button>
<div>
<table style='text-align: left; width: 100%; vertical-align: middle;'>
<tr>
<td>Tên khách hàng</td>
<td>Nguyễn Văn Tư</td>
</tr>
<tr>
<td>Mã khách hàng</td>
<td>PC06LL0191387</td>
</tr>
<tr>
<td>Sery công tơ</td>
<td>14138734</td>
</tr>
<tr>
<td>Chỉ số cũ</td>
<td>194.000</td>
</tr>
<tr>
<td>Chỉ số mới</td>
<td>196.60</td>
</tr>
<tr>
<td>Sản lượng mới</td>
<td>2</td>
</tr>
</table>
</div>
<input class='toggle-box' id='header2' type='radio' name="radio" /><label for='header2'>ĐInh Thị Tha</label>
<button type="reset">ĐInh Thị Tha</button>
<div>
<table style='text-align: left; width: 100%; vertical-align: middle;'>
<tr>
<td>Tên khách hàng</td>
<td>ĐInh Thị Tha</td>
</tr>
<tr>
<td>Mã khách hàng</td>
<td>PC06LL0182038</td>
</tr>
<tr>
<td>Sery công tơ</td>
<td>14140069</td>
</tr>
<tr>
<td>Chỉ số cũ</td>
<td>2050.000</td>
</tr>
<tr>
<td>Chỉ số mới</td>
<td>2104.10</td>
</tr>
<tr>
<td>Sản lượng mới</td>
<td>54</td>
</tr>
</table>
</div>
<input class='toggle-box' id='header3' type='radio' name="radio" /><label for='header3'>Nguyễn Văn Nhựt</label>
<button type="reset">Nguyễn Văn Nhựt</button>
<div>
<table style='text-align: left; width: 100%; vertical-align: middle;'>
<tr>
<td>Tên khách hàng</td>
<td>Nguyễn Văn Nhựt</td>
</tr>
<tr>
<td>Mã khách hàng</td>
<td>PC06LL0190775</td>
</tr>
<tr>
<td>Sery công tơ</td>
<td>14138746</td>
</tr>
<tr>
<td>Chỉ số cũ</td>
<td>2699.000</td>
</tr>
<tr>
<td>Chỉ số mới</td>
<td>2785.10</td>
</tr>
<tr>
<td>Sản lượng mới</td>
<td>86</td>
</tr>
</table>
</div>
<input class='toggle-box' id='header4' type='radio' name="radio" /><label for='header4'>Mai Văn Lý</label>
<button type="reset">Mai Văn Lý</button>
<div>
<table style='text-align: left; width: 100%; vertical-align: middle;'>
<tr>
<td>Tên khách hàng</td>
<td>Mai Văn Lý</td>
</tr>
<tr>
<td>Mã khách hàng</td>
<td>PC06LL0182035</td>
</tr>
<tr>
<td>Sery công tơ</td>
<td>14138744</td>
</tr>
<tr>
<td>Chỉ số cũ</td>
<td>2581.000</td>
</tr>
<tr>
<td>Chỉ số mới</td>
<td>2631.70</td>
</tr>
<tr>
<td>Sản lượng mới</td>
<td>50</td>
</tr>
</table>
</div>
</div>
</form>
http://jsbin.com/pefobi
Note: If you need that the second click will close the tab again, you have to wrap all with form tag.

Related

Half Sticky Table with Html and Css

I have a table like in the picture:
What I am trying to achieve is I want the total part sticky on the table and Math, History and Biology etc. should be able to scroll right. S now the Math is next to the Total but I want History or Biology should be able to next to Total also.
Until now my code is like this:
.last-workouts .last-workout-table {
border-radius: 20px;
}
.last-workouts table {
border-collapse: collapse;
border-spacing: 0;
width: 100%;
border: 1px solid #ddd;
}
.last-workouts table .tests:not(:last-child) {
border-bottom: 1px solid #050a6c;
}
.last-workouts .test {
background-color: #00bad6;
text-align: center;
color: #FFFFFF;
padding: 1rem 0;
width: 20%;
}
.last-workouts .test .number-test,
.last-workouts .test .type-test {
font-weight: bold;
}
.last-workouts .result {
margin: 0;
padding: 0;
text-align: center;
width: 12%;
background-color: #F0F0F0;
}
.last-workouts .inner-table {
border: none;
}
.last-workouts .inner-table tr:not(:last-child) {
border-bottom: 1px solid #a9a9a9;
}
.last-workouts .total {
color: #00bad6;
font-weight: bold;
padding: .25rem;
}
.last-workouts .inner-table .box td {
padding: 0.5rem;
border: 1px solid #a9a9a9;
}
.last-workouts .inner-table .box .bold {
font-weight: bold;
}
.last-workouts .inner-table .box .bold.red {
color: red;
}
.last-workouts .inner-table .box div {
padding: .5rem;
}
.last-workouts .lessons {
margin: 0;
padding: 0;
text-align: center;
width: 12%;
}
.last-workouts .lessons:not(:last-child) {
border-right: 2px solid #000000;
}
<div class="last-workouts">
<div style="overflow-x:auto;" class="last-workout-table">
<table>
<tr class="tests">
<td class="test">
<div class="number-test">TYT-1</div>
<div class="type-test">Genel Deneme</div>
<div class="date">30.08.2021</div>
</td>
<td class="result">
<div class="total">
Toplam
</div>
<table class="inner-table">
<tr class="box">
<td>S</td>
<td>D</td>
<td>Y</td>
<td>B</td>
<td class="bold">Net</td>
<td class="bold">Puan</td>
</tr>
<tr class="box">
<td>115</td>
<td>80</td>
<td>6</td>
<td>16</td>
<td class="bold red">17.48</td>
<td class="bold red">490,54</td>
</tr>
</table>
</td>
<td class="lessons">
<div class="total">
Matematik
</div>
<table class="inner-table">
<tr class="box">
<td>S</td>
<td>D</td>
<td>Y</td>
<td>B</td>
<td class="bold">Net</td>
<td class="bold">Puan</td>
</tr>
<tr class="box">
<td>115</td>
<td>80</td>
<td>6</td>
<td>16</td>
<td class="bold red">17.48</td>
<td class="bold red">490,54</td>
</tr>
</table>
</td>
<td class="lessons">
<div class="total">
Turkce
</div>
<table class="inner-table">
<tr class="box">
<td>S</td>
<td>D</td>
<td>Y</td>
<td>B</td>
<td class="bold">Net</td>
<td class="bold">Puan</td>
</tr>
<tr class="box">
<td>115</td>
<td>80</td>
<td>6</td>
<td>16</td>
<td class="bold red">17.48</td>
<td class="bold red">490,54</td>
</tr>
</table>
</td>
<td class="lessons">
<div class="total">
Tarih
</div>
<table class="inner-table">
<tr class="box">
<td>S</td>
<td>D</td>
<td>Y</td>
<td>B</td>
<td class="bold">Net</td>
<td class="bold">Puan</td>
</tr>
<tr class="box">
<td>115</td>
<td>80</td>
<td>6</td>
<td>16</td>
<td class="bold red">17.48</td>
<td class="bold red">490,54</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</div>
So how do you think I can achieve this?
Thanks
Nest .test and .result in an inner table and add position: sticky; left: 0; to the outer td.
.last-workouts .last-workout-table {
border-radius: 20px;
}
.last-workouts table {
border-collapse: collapse;
border-spacing: 0;
width: 100%;
border: 1px solid #ddd;
}
.last-workouts table .tests:not(:last-child) {
border-bottom: 1px solid #050a6c;
}
.last-workouts .test {
background-color: #00bad6;
text-align: center;
color: #FFFFFF;
padding: 1rem 0;
width: 20%;
}
.last-workouts .test .number-test,
.last-workouts .test .type-test {
font-weight: bold;
}
.last-workouts .result {
margin: 0;
padding: 0;
text-align: center;
width: 12%;
background-color: #F0F0F0;
}
.last-workouts .inner-table {
border: none;
}
.last-workouts .inner-table tr:not(:last-child) {
border-bottom: 1px solid #a9a9a9;
}
.last-workouts .total {
color: #00bad6;
font-weight: bold;
padding: .25rem;
}
.last-workouts .inner-table .box td {
padding: 0.5rem;
border: 1px solid #a9a9a9;
}
.last-workouts .inner-table .box .bold {
font-weight: bold;
}
.last-workouts .inner-table .box .bold.red {
color: red;
}
.last-workouts .inner-table .box div {
padding: .5rem;
}
.last-workouts .lessons {
margin: 0;
padding: 0;
text-align: center;
width: 12%;
}
.last-workouts .lessons:not(:last-child) {
border-right: 2px solid #000000;
}
<div class="last-workouts">
<div style="overflow-x:auto;" class="last-workout-table">
<table>
<tr class="tests">
<td style="position: sticky; left: 0;">
<table>
<td class="test">
<div class="number-test">TYT-1</div>
<div class="type-test">Genel Deneme</div>
<div class="date">30.08.2021</div>
</td>
<td class="result">
<div class="total">
Toplam
</div>
<table class="inner-table">
<tr class="box">
<td>S</td>
<td>D</td>
<td>Y</td>
<td>B</td>
<td class="bold">Net</td>
<td class="bold">Puan</td>
</tr>
<tr class="box">
<td>115</td>
<td>80</td>
<td>6</td>
<td>16</td>
<td class="bold red">17.48</td>
<td class="bold red">490,54</td>
</tr>
</table>
</td>
</table>
</td>
<td class="lessons">
<div class="total">
Matematik
</div>
<table class="inner-table">
<tr class="box">
<td>S</td>
<td>D</td>
<td>Y</td>
<td>B</td>
<td class="bold">Net</td>
<td class="bold">Puan</td>
</tr>
<tr class="box">
<td>115</td>
<td>80</td>
<td>6</td>
<td>16</td>
<td class="bold red">17.48</td>
<td class="bold red">490,54</td>
</tr>
</table>
</td>
<td class="lessons">
<div class="total">
Turkce
</div>
<table class="inner-table">
<tr class="box">
<td>S</td>
<td>D</td>
<td>Y</td>
<td>B</td>
<td class="bold">Net</td>
<td class="bold">Puan</td>
</tr>
<tr class="box">
<td>115</td>
<td>80</td>
<td>6</td>
<td>16</td>
<td class="bold red">17.48</td>
<td class="bold red">490,54</td>
</tr>
</table>
</td>
<td class="lessons">
<div class="total">
Tarih
</div>
<table class="inner-table">
<tr class="box">
<td>S</td>
<td>D</td>
<td>Y</td>
<td>B</td>
<td class="bold">Net</td>
<td class="bold">Puan</td>
</tr>
<tr class="box">
<td>115</td>
<td>80</td>
<td>6</td>
<td>16</td>
<td class="bold red">17.48</td>
<td class="bold red">490,54</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</div>

CSS Custom Radio Buttons don't work properly

I'm trying to build my custom radio buttons. I want them to just have a bigger, white border and when the radio button is checked I want to have a white dot in it. Like so:
https://ibb.co/iBjJHk
But it's not working, I can't check the radio button anymore...
I'm searching for a pure CSS solution if possible.
Here is what I tried so far, the relevant part is at the top of the CSS.
https://codepen.io/Insane415/pen/zzoBmp
HTML
<table class="pricing-table">
<tr>
<td id="table-heading"><h1>Leistungen & Preise Telefonservice</h2></td>
<td>
<label for="test">AllIn-Order</label>
<input type="radio" id="test" name="tarif-top">
</td>
<td class="red-background">AllIn-Time<br>
<input type="radio" checked name="tarif-top" value="allin-time"/></td>
<td>AllIn-Contact<br>
<input type="radio" name="tarif-top" value="allin-contact"/></td>
<td>
Enterprise<br>
<input type="radio" name="tarif-top" value="enterprise"/>
</td>
</tr>
<tr>
<td>Monatliche Grundgebühr</td>
<td colspan="3">nur 59,90€</td>
<td>individuell</td>
</tr>
<tr>
<td>Telefonische Annahmezeit</td>
<td colspan="3">Mo-Fr 08:00 bis 19:00 Uhr</td>
<td>24/7</td>
</tr>
<tr>
<td>Kosten pro Minute/Kontakt</td>
<td>0,69€/Minute</td>
<td class="red-background">0,89€/Minute</td>
<td>3,00€/Kontakt</td>
<td>individuell</td>
</tr>
<tr>
<td>Transaktionsgebühren</td>
<td>12,5%/Bestellung</td>
<td class="red-background">—</td>
<td>—</td>
<td>individuell</td>
</tr>
<tr id="services">
<td>Enthaltene Leistungen</td>
</tr>
<tr>
<td>Englischsprachiger Telefonservice</td>
<td colspan="3">Check</td>
<td>Check</td>
</tr>
<tr>
<td>Kundenservice für Markplätze</td>
<td colspan="3">Check</td>
<td>Check</td>
</tr>
<tr>
<td>Bestellannahme für Waren</td>
<td colspan="3">Check</td>
<td>Check</td>
</tr>
<tr>
<td>Anrufnotiz via E-Mail</td>
<td colspan="3">Check</td>
<td>Check</td>
</tr>
<tr>
<td>Anrufnotiz via E-Mail</td>
<td colspan="3">Check</td>
<td>Check</td>
</tr>
<tr>
<td>Monatliches Reporting</td>
<td colspan="3">Check</td>
<td>Check</td>
</tr>
<tr>
<td>Weiterleitung Festnetz (DE)</td>
<td colspan="3">0,09€/Minute</td>
<td>Check</td>
</tr>
<tr>
<td>Weiterleitung Mobilfunknetz (DE)</td>
<td colspan="3">0,25€/Minute</td>
<td>Check</td>
</tr>
<tr>
<td>Buchungsannahme</td>
<td colspan="3">—</td>
<td>Check</td>
</tr>
<tr>
<td>Outbound-Kampagnen</td>
<td colspan="3">—</td>
<td>Check</td>
</tr>
<tr>
<td></td>
<td>
<input type="radio" value="allin-order" name="tarif-bottom"/>
<br>AllIn-Order
</td>
<td class="red-background">
<input type="radio" checked name="tarif-bottom" value="allin-time"/>
<br>AllIn-Time
</td>
<td>
<input type="radio" name="tarif-bottom" value="allin-contact"/>
<br>AllIn-Contact
</td>
<td>
<input type="radio" name="tarif-bottom" value="enterprise"/>
<br>Enterprise
</td>
</tr>
</table>
CSS
/*BEGIN Custom Radio Button*/
#test{
display: none;
}
label:before{
content: '';
width: 25px;
height: 25px;
border: 3px solid white;
display: inline-block;
border-radius: 100%;
position: absolute;
top: 50px;
}
input[type="radio"]:checked + label:after{
content: '';
width: 15px;
height: 15px;
border-radius: 100%;
background-color: white;
display: inline-block;
}
label:hover{
cursor: pointer;
}
/*END Custom Radio Button*/
.pricing-table{
text-align: center;
}
.pricing-table td{
background-color: #ccc;
padding: 12px;
}
.pricing-table tr td:first-child{
background-color: #ddd;
text-align: left;
}
.pricing-table tr td:last-child{
}
.pricing-table tr:last-child td:first-child{
background-color: white;
}
.pricing-table #services td, #table-heading{
font-weight: 600;
background-color: white;
}
.pricing-table tr:first-child td:nth-of-type(1n+2), .pricing-table tr:last-child td {
background-color: #545067;
color: white;
}
.red-background{
color: white!important;
background-color: #E22C26!important;
}
/* BEGIN Radio Buttons*/
/*END Radio Buttons*/
.tarif-choice hr{
border-color: #E22C26;
}
ul.optional {
background-color: #ddd;
padding: 0;
}
ul.optional input{
margin-right: 10px;
margin-left: 15px;
}
ul.optional li{
list-style-type: none;
border-top: 1px solid silver;
}
ul.optional p{
margin-left: 30px;
margin-top: 0;
margin-bottom: 0;
}
ul.optional p:before {
content: "•";
margin-right: 6px;
}
.checkbox-holder{
margin-left: 25px;
}
.checkbox-holder .checkbox-space{
margin-left: 50px;
}
Please see below. Added CSS for label and fixed a few settings for label:after. Since your CSS uses input + label, it is important input is specified before the label in your HTML (changed below).
$('input[type="radio"]').change(function(){
if($(this).val()=='allin-order'){
$(":radio[value=allin-order]").prop("checked", true);
$(".pricing-table td").removeClass("red-background");
$(".pricing-table tr:first-child td:nth-of-type(2)").addClass("red-background");
$(".pricing-table tr:nth-of-type(4) td:nth-of-type(2)").addClass("red-background");
$(".pricing-table tr:nth-of-type(5) td:nth-of-type(2)").addClass("red-background");
$(".pricing-table tr:last-child td:nth-of-type(2)").addClass("red-background");
};
if($(this).val()=='allin-time'){
$(":radio[value=allin-time]").prop("checked", true);
$(".pricing-table td").removeClass("red-background");
$(".pricing-table tr:first-child td:nth-of-type(3)").addClass("red-background");
$(".pricing-table tr:nth-of-type(4) td:nth-of-type(3)").addClass("red-background");
$(".pricing-table tr:nth-of-type(5) td:nth-of-type(3)").addClass("red-background");
$(".pricing-table tr:last-child td:nth-of-type(3)").addClass("red-background");
};
if($(this).val()=='allin-contact'){
$(":radio[value=allin-contact]").prop("checked", true);
$(".pricing-table td").removeClass("red-background");
$(".pricing-table tr:first-child td:nth-of-type(4)").addClass("red-background");
$(".pricing-table tr:nth-of-type(4) td:nth-of-type(4)").addClass("red-background");
$(".pricing-table tr:nth-of-type(5) td:nth-of-type(4)").addClass("red-background");
$(".pricing-table tr:last-child td:nth-of-type(4)").addClass("red-background");
};
if($(this).val()=='enterprise'){
$(":radio[value=enterprise]").prop("checked", true);
$(".pricing-table td").removeClass("red-background");
$(".pricing-table tr:first-child td:nth-of-type(5)").addClass("red-background");
$(".pricing-table tr:nth-of-type(4) td:nth-of-type(5)").addClass("red-background");
$(".pricing-table tr:nth-of-type(5) td:nth-of-type(5)").addClass("red-background");
$(".pricing-table tr:last-child td:nth-of-type(5)").addClass("red-background");
};
});
/*BEGIN Custom Radio Button*/
#test{
display: none;
}
label { display: inline-block; position: relative; }
label:after{
content: '';
width: 25px;
height: 25px;
border: 3px solid white;
border-radius: 50%;
position: absolute;
top: 25px;
right: 25px;
}
input[type="radio"]:checked + label:after{
content: '';
width: 25px;
height: 25px;
border: 3px solid white;
border-radius: 50%;
background: white;
display: inline-block;
}
label:hover{
cursor: pointer;
}
/*END Custom Radio Button*/
.pricing-table{
text-align: center;
}
.pricing-table td{
background-color: #ccc;
padding: 12px;
}
.pricing-table tr td:first-child{
background-color: #ddd;
text-align: left;
}
.pricing-table tr td:last-child{
}
.pricing-table tr:last-child td:first-child{
background-color: white;
}
.pricing-table #services td, #table-heading{
font-weight: 600;
background-color: white;
}
.pricing-table tr:first-child td:nth-of-type(1n+2), .pricing-table tr:last-child td {
background-color: #545067;
color: white;
}
.red-background{
color: white!important;
background-color: #E22C26!important;
}
/* BEGIN Radio Buttons*/
/*END Radio Buttons*/
.tarif-choice hr{
border-color: #E22C26;
}
ul.optional {
background-color: #ddd;
padding: 0;
}
ul.optional input{
margin-right: 10px;
margin-left: 15px;
}
ul.optional li{
list-style-type: none;
border-top: 1px solid silver;
}
ul.optional p{
margin-left: 30px;
margin-top: 0;
margin-bottom: 0;
}
ul.optional p:before {
content: "•";
margin-right: 6px;
}
.checkbox-holder{
margin-left: 25px;
}
.checkbox-holder .checkbox-space{
margin-left: 50px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table class="pricing-table">
<tr>
<td id="table-heading"><h1>Leistungen & Preise Telefonservice</h2></td>
<td>
<input type="radio" id="test" name="tarif-top">
<label for="test">AllIn-Order</label>
</td>
<td class="red-background">AllIn-Time<br>
<input type="radio" checked name="tarif-top" value="allin-time"/></td>
<td>AllIn-Contact<br>
<input type="radio" name="tarif-top" value="allin-contact"/></td>
<td>
Enterprise<br>
<input type="radio" name="tarif-top" value="enterprise"/>
</td>
</tr>
<tr>
<td>Monatliche Grundgebühr</td>
<td colspan="3">nur 59,90€</td>
<td>individuell</td>
</tr>
<tr>
<td>Telefonische Annahmezeit</td>
<td colspan="3">Mo-Fr 08:00 bis 19:00 Uhr</td>
<td>24/7</td>
</tr>
<tr>
<td>Kosten pro Minute/Kontakt</td>
<td>0,69€/Minute</td>
<td class="red-background">0,89€/Minute</td>
<td>3,00€/Kontakt</td>
<td>individuell</td>
</tr>
<tr>
<td>Transaktionsgebühren</td>
<td>12,5%/Bestellung</td>
<td class="red-background">—</td>
<td>—</td>
<td>individuell</td>
</tr>
<tr id="services">
<td>Enthaltene Leistungen</td>
</tr>
<tr>
<td>Englischsprachiger Telefonservice</td>
<td colspan="3">Check</td>
<td>Check</td>
</tr>
<tr>
<td>Kundenservice für Markplätze</td>
<td colspan="3">Check</td>
<td>Check</td>
</tr>
<tr>
<td>Bestellannahme für Waren</td>
<td colspan="3">Check</td>
<td>Check</td>
</tr>
<tr>
<td>Anrufnotiz via E-Mail</td>
<td colspan="3">Check</td>
<td>Check</td>
</tr>
<tr>
<td>Anrufnotiz via E-Mail</td>
<td colspan="3">Check</td>
<td>Check</td>
</tr>
<tr>
<td>Monatliches Reporting</td>
<td colspan="3">Check</td>
<td>Check</td>
</tr>
<tr>
<td>Weiterleitung Festnetz (DE)</td>
<td colspan="3">0,09€/Minute</td>
<td>Check</td>
</tr>
<tr>
<td>Weiterleitung Mobilfunknetz (DE)</td>
<td colspan="3">0,25€/Minute</td>
<td>Check</td>
</tr>
<tr>
<td>Buchungsannahme</td>
<td colspan="3">—</td>
<td>Check</td>
</tr>
<tr>
<td>Outbound-Kampagnen</td>
<td colspan="3">—</td>
<td>Check</td>
</tr>
<tr>
<td></td>
<td>
<input type="radio" value="allin-order" name="tarif-bottom"/>
<br>AllIn-Order
</td>
<td class="red-background">
<input type="radio" checked name="tarif-bottom" value="allin-time"/>
<br>AllIn-Time
</td>
<td>
<input type="radio" name="tarif-bottom" value="allin-contact"/>
<br>AllIn-Contact
</td>
<td>
<input type="radio" name="tarif-bottom" value="enterprise"/>
<br>Enterprise
</td>
</tr>
</table>
<!-- END table -->
<h2>Buchungsübersicht</h2>
<div class="row">
<div class="col-md-6">
<div class="tarif-choice">
<p>Ihre Tarifauswahl</p>
<hr/>
<div class="allin-time">
<ul>
<li>mtl. Grundgebühr 59,90€</li>
<li>0,89€/Minute</li>
<li>Servicezeit: Mo-Fr 08:00-19:00 Uhr</li>
</ul>
<ul class="check">
<li>Mehrsprachiger Telefonservice</li>
<li>Bestellannahme für Waren</li>
<li>Buchungsannahme</li>
<li>Anrufnotiz via E-Mail</li>
<li>Monatliches Reporting</li>
<li>Einzelverbindungsnachweis</li>
</ul>
</div>
</div>
</div>
<div class="col-md-6">
<p>Optionale Leistungen | | Diese Leistungen werden nur abgerechnet,
soweit Sie sich aktiv für den Service entschieden haben
<ul class="optional">
<li><input type="checkbox"/>Service Zeit 24/7
<p class="dot">Kosten: 19,90 €/E-Mail</p>
</li>
<li><input type="checkbox"/>Anrufnotiz via SMS
<p class="dot">Kosten: 0,20 €/SMS</p>
</li>
<li><input type="checkbox"/>E-Mail-Service
<p class="dot">Servicezeit: Mo-Fr 08:00-19:00 Uhr</p>
<p class="dot">Kosten: 4,49 €/E-Mail</p>
</li>
<li><input type="checkbox"/>Chat-Service
<p class="dot"/>Live-Chat. WhatsApp & Facebook-Messenger Service</p>
<p class="dot"/>Servicezeit: Mo-Fr 08:00-19:00 Uhr</p>
<p class="dot"/>Kosten (2 Abrechnungsmodelle möglich): </p>
<div class="checkbox-holder">
<input type="checkbox"/>5,49€/Chat
<span class="checkbox-space"><input type="checkbox"/>0,69€/Minute</span>
</div>
</li>
<li><input type="checkbox"/>Click-to-Message Service
<p class="dot"/>Servicezeit: Mo-Fr 08:00-19:00 Uhr</p>
<p class="dot">0,20 €/SMS</p>
</li>
</ul>
</div>
</div>

CSS class selector not working but tag and class selector does

When I use a class selector to modify the width of an element it does not work. When I use a tag and class selector as in table.change-name it does work.
HTML:
<!-- start settings -->
<div class='settings'>
<h4>Account Settings</h4>
<table class='options'>
<tr>
<td class='name username'>Name</td>
<td class='value'>Robert Rocha</td>
<td class='edit'><a href='#'>Edit</a></td>
</tr>
<tr>
<td class='name email'>Email</td>
<td class='value'>tom#gmail.com</td>
<td class='edit'><a href='#'>Edit</a></td>
</tr>
<tr>
<td class='name pword' colspan='2'>Password</td>
<td class='edit'><a href='#'>Edit</a></td>
</tr>
<tr>
<td class='name remove-all' colspan='3'><a href='#'>Delete All Photos</a></td>
</tr>
<tr>
<td class='name remove-account' colspan='3'><a href='#'>Delete Account</a></td>
</tr>
</table>
<table class='change-name'>
<tr>
<td class='first'>First</td>
<td><input type='text' name='fname' class='fname'></td>
</tr>
<tr>
<td class='middle'>Middle</td>
<td><input type='text' name='mname' class='mname'></td>
</tr>
<tr>
<td class='last'>Last</td>
<td><input type='text' name='lname' class='lname'></td>
</tr>
<tr>
<td class='save'><a href='#'>Save</a></td>
<td class='cancel'><a href='#'>Cancel</a></td>
</tr>
</table>
</div>
<!-- end settings -->
CSS:
/* Settings */
.settings {
width: 650px;
margin: 0 auto;
padding: 1em;
}
.settings h4 {
padding: 1em 0;
letter-spacing: 1px;
border-bottom: 1px solid #cacece;
}
.settings table {
width: 100%;
font-size: 0.9em;
letter-spacing: 1px;
font-weight: 200;
table-layout: fixed;
}
.settings tr { border-bottom: 1px solid #cacece; }
.settings td { padding: 0.5em 0; }
.settings .edit { text-align: right; }
.settings .name { font-weight: bold; }
.settings .remove-all, .settings .remove-account { font-weight: 200; }
/* Change Name Table */
.change-name {
background: #cacece;
width: 300px;
}
.change-name tr { border: none; }
Result: https://jsfiddle.net/yy1mu2ze/
If I do the following:
table.change-name {
background: #cacece;
width: 300px;
}
I get: https://jsfiddle.net/yy1mu2ze/1/
Why is this?

Showing two things when hoverd

I have a title and when i hoverd i would like that it would show two difrent tables. Is that possible?
I tride this one:
#ArijsLieve:hover ~ #arijslievetable ~ #arijslievefototable { display: block; }
but this only shows the #arijslievefototable.
my full code in html:
<div id="ArijsLieve">
<h3> Arijs Lieve </h3>
</div>
<table id="arijslievetable">
<tr>
<td> Kleuters 3j woensdag </td>
</tr>
<tr>
<td> Kleuters 4j woensdag </td>
</tr>
<tr>
<td> Kleuters 5j woensdag </td>
</tr>
<tr>
<td> Team acro competitie </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> E-mail: </td>
</tr>
<tr>
<td> jenskemeert#hotmail.com </td>
</tr>
</table>
<table id="arijslievefototable">
<tr>
<td> <img src="lieve_arijs.jpg" alt="lieve_arijs" width=100 height=100 /> </td>
</tr>
</table>
and css:
#ArijsLieve{background: #333; color: white; width: 100px; text-align: center; position: relative; top: -300px; left: 265px; cursor: pointer; }
`#arijslievetable{ background: #333; color: white; width: 810px; position: absolute; top: 701px; left: 273px; display: none; }
#ArijsLieve:hover ~ #arijslievetable ~ #arijslievefototable { display: block; }
#arijslievefototable{ background: #333; width: 1px; position:absolute; top: 701px; left: 976px; display: none;}
should be this
#ArijsLieve:hover ~ #arijslievetable,
#ArijsLieve:hover ~ #arijslievefototable { display: block; }

DataTables Padding Top 0 How To Set

I have 3 DataTables tables. Their ID's are #example2,#example2,#example3.
I have a problem with padding top 0, i want to set padding top 0 but after trying many hours i am exhausted.
MARKUP:
<table>
<tr>
<td width="850px">
<div></div>
<div>
<table id="example2" class="display" cellspacing="0">
<thead>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>
<td></td>
<td></td>
<td>
<table>{
<tr>
<td></td>
</tr>}</table>
</td>
</tr>}</tbody>
</table>
</div>
</td>
<td class="padding" width="850px">
<div></div>
<div>
<table id="example3" class="display" cellpadding="0px">
<thead>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
<td>
<table>
<tr>
<td></td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</td>
<td width="850px">
<div></div>
<div>
<table id="example4" class="display" cellspacing="0">
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
<table>
<tr>
<td </td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
</table>
CSS:
<style> td.padding {
padding-top: 0cm;
}
</style> <style> table.dataTable.row-border tbody th, table.dataTable.row-border tbody td, table.dataTable.display tbody th, table.dataTable.display tbody td {
border-top: 1px solid #D7E4DB;
border-bottom: 1px solid #D7E4DB;
}
</style> <style> #example.dataTable {
margin-left: 0px !important;
margin-right: 0px !important;
margin-bottom: 0px !important;
margin-top: 0px !important;
text-align: center;
}
</style> <style> #example_filter.dataTables_filter {
width: 100%;
/*float: left;*/
text-align: center;
}
.DTTT_container {
width: 100%;
/*float: left;*/
text-align: center;
}
#example.dataTable {
margin-top: 0px !important;
text-align: center;
margin-left: auto;
margin-right: auto;
}
.dataTable {
margin-top: 0px !important;
text-align: center;
margin-left: auto;
margin-right: auto;
}
#example.display.dataTable {
margin-top: 0px !important;
text-align: center;
margin-left: auto;
margin-right: auto;
}
table.dataTable {
width: 100%;
}
</style>