My tables display fine on desktop, but once I try to view the mobile version my table ends up being too wide for the mobile device screen. I am using a responsive layout.
<
After researching for almost 1 month i found the below code which is working very beautifully and 100% perfectly on my website. To check the preview how it is working you can check from the link. https://www.jobsedit.in/state-government-jobs/
CSS CODE-----
@media only screen and (max-width: 500px) {
.resp table {
display: block ;
}
.resp th {
position: absolute;
top: -9999px;
left: -9999px;
display:block ;
}
.resp tr {
border: 1px solid #ccc;
display:block;
}
.resp td {
/* Behave like a "row" */
border: none;
border-bottom: 1px solid #eee;
position: relative;
width:100%;
background-color:White;
text-indent: 50%;
text-align:left;
padding-left: 0px;
display:block;
}
.resp td:nth-child(1) {
border: none;
border-bottom: 1px solid #eee;
position: relative;
font-size:20px;
text-indent: 0%;
text-align:center;
}
.resp td:before {
/* Now like a table header */
position: absolute;
/* Top/left values mimic padding */
top: 6px;
left: 6px;
width: 45%;
text-indent: 0%;
text-align:left;
white-space: nowrap;
background-color:White;
font-weight:bold;
}
/*
Label the data
*/
.resp td:nth-of-type(2):before { content: attr(data-th) }
.resp td:nth-of-type(3):before { content: attr(data-th) }
.resp td:nth-of-type(4):before { content: attr(data-th) }
.resp td:nth-of-type(5):before { content: attr(data-th) }
.resp td:nth-of-type(6):before { content: attr(data-th) }
.resp td:nth-of-type(7):before { content: attr(data-th) }
.resp td:nth-of-type(8):before { content: attr(data-th) }
.resp td:nth-of-type(9):before { content: attr(data-th) }
.resp td:nth-of-type(10):before { content: attr(data-th) }
}
HTML CODE --