I am trying to make my table responsive but its not happening. I don't know where is the problem. I am using bootstrap-responsive.css to make it happen, but the table is not breaking like other pages break when I open in mobile.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Untitled Document</title>
<link href="css/bootstrap.css" rel="stylesheet"/>
<link type="text/css" href="css/bootstrap-responsive.css" rel="stylesheet" />
<script src="test/bootstrap.js"></script>
<script src="js/jquery.js"></script>
<script src="js/bootstrap-transition.js"></script>
<script src="js/bootstrap-modal.js"></script>
<script src="js/bootstrap-dropdown.js"></script>
<link href="css/bootstrap-combined.css" rel="stylesheet">
<link type="text/css" href="js/template.css" rel="stylesheet" />
<link href="test/flip-scroll.css" rel="stylesheet">
<style>
#tbl{
border: thin solid #eee;
}
#tbl td{
padding:5px;
border-bottom: thin solid #C4C4C4;
border-right:thin solid #eee;
}
#tbl tr:last-child td{
border-bottom:none;
}
#tbl td:last-child{
border-right:none;
}
#tbl tr:nth-child(odd){ background-color:#dafaf6; }
.heading{
color:#FFFFFF;
font-size:14px;
padding:10px;
text-align:center;
}
.clear
{
height:70px;
}
.current a
{
color:#FFF;
}
.divDemoBody {
width: 60%;
margin-left: auto;
margin-right: auto;
margin-top: 100px;
}
.divDemoBody p {
font-size: 18px;
line-height: 140%;
padding-top: 12px;
}
.divDialogElements input {
font-size: 18px;
padding: 3px;
height: 32px;
width: 500px;
}
.divButton {
padding-top: 12px;
}
</style>
</head>
<body>
<div style="width:100%; background-color:#1d719a; height:100px;">
<img src="nature/logo.png" style="margin:23px 0px 0px 30px;">
<div style="width:30%; float:right; text-align:right; margin-right:20px; margin-top:20px;">
<img src="images/home_icon.png" height="32" width="32"/>
<img src="images/logout.png" height="32" width="32" />
</div>
</div>
<div class="row" style="margin-left:50px; margin-top:50px">
<div class="span12" align="center">
<form method="get" action="/" class="form-inline" >
<input name="q" class="span5" type="text" placeholder="Keywords:Name" >
<button type="submit" class="btn btn-small btn-primary">Search<i class="icon-search icon-white"></i></button>
</form>
</div>
</div>
<div class="container" style="margin-top:60px;">
<div class="row-fluid">
<div class="span12">
<legend style="font-family:Georgia, 'Times New Roman', Times, serif; font-style:italic; color:#06C;">Patient Details</legend>
<table align="right" style="margin-right:50px"><tr><td><div class="pagination"><ul><li class="active"><a>1</a></li><li>2</li><li>3</li><li>»</li></ul></div></td></tr> </table>
<table cellpadding="0px" cellspacing="0px" border="0" style="width:90%" align="center">
<tr>
<td>
<section id="flip-scroll" style="margin-left:40px; width:100%">
<table class="table-bordered table-striped table-condensed cf" style="width:95%; ">
<thead style="background-color:#045c97;">
<tr>
<th class="heading">Patient Name</th>
<th class="heading">Date OF Birth</th>
<th class="heading" >Subject</th>
<th class="heading">Progress Note Date</th>
<th class="heading">Provider</th>
<th class="heading">Action</th>
</tr>
</thead>
<tbody style="font-size:12px;">
<tr>
<td>Shiv Acharya</td>
<td>06-03-1991</td>
<td>Suffering From high Fever</td>
<td>12-04-2013</td>
<td>SA</td>
<td>
<div class="dropdown btn-group">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#"> Actions
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li>Edit Demographics</li>
<li>New Encounter</li>
<li>View Past Notes</li>
</ul>
</div>
</td>
</tr>
<tr>
<td>Biswajeet Mahapatra</td>
<td>09-08-1991</td>
<td>Suffering From back pain</td>
<td>12-04-2013</td>
<td>BM</td>
<td>
<div class="dropdown btn-group">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
Actions
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li>Edit Demographics</li>
<li>New Encounter</li>
<li>View Past Notes</li>
</ul>
</div>
</td>
</tr>
<tr>
<td>Praveen jena</td>
<td>06-03-1991</td>
<td>Suffering From heart attack</td>
<td>12-04-2013</td>
<td>SJ</td>
<td>
<div class="dropdown btn-group">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#"> Actions
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li>Edit Demographics</li>
<li>New Encounter</li>
<li>View Past Notes</li>
</ul>
</div>
</td>
</tr>
<tr>
<td>Sahil Sahoo</td>
<td>06-03-1991</td>
<td>Suffering From heart attack</td>
<td>12-04-2013</td>
<td>SJ</td>
<td><div class="btn-group">
<div class="dropdown btn-group">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
Actions
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li>Edit Demographics</li>
<li>New Encounter</li>
<li>View Past Notes</li>
</ul>
</div>
</td>
</tr>
<tr>
<td>Akash Pattnaik</td>
<td>06-03-1991</td>
<td>Suffering From heart attack</td>
<td>12-04-2013</td>
<td>SJ</td>
<td><div class="btn-group">
<div class="dropdown btn-group">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#"> Actions
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li>Edit Demographics</li>
<li>New Encounter</li>
<li>View Past Notes</li>
</ul>
</div>
</td>
</tr>
<tr>
<td>Sheetam kumar jena</td>
<td>06-03-1991</td>
<td>Suffering From heart attack</td>
<td>12-04-2013</td>
<td>SJ</td>
<td>
<div class="dropdown btn-group">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#"> Actions
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li>Edit Demographics</li>
<li>New Encounter</li>
<li>View Past Notes</li>
</ul>
</div>
</td>
</tr>
</tbody>
</table>
<div class="clear"> </div>
</section>
<!-- <table cellspacing="0" cellpadding="2" border="0" id="tbl" style="width:100%">
<tr style="background-color:#045c97">
<td class="heading">Patient Name</td>
<td class="heading">Date OF Birth</td>
<td class="heading">Subject</td>
<td class="heading">Progress Note Date</td>
<td class="heading">Provider</td>
<td class="heading">Action</td>
</tr>
<tr style="text-align:center;">
<td>Shiv Acharya</td>
<td>06-03-1991</td>
<td>Suffering From high Fever</td>
<td>12-04-2013</td>
<td>SA</td>
<td>
<div class="dropdown btn-group">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#"> Actions
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li>Edit Demographics</li>
<li>New Encounter</li>
<li>View Pastvotes</li>
</ul>
</div>
</td>
</tr>
<tr style="text-align:center;">
<td>Biswajeet Mahapatra</td>
<td>09-08-1991</td>
<td>Suffering From back pain</td>
<td>12-04-2013</td>
<td>BM</td>
<td><div class="dropdown btn-group">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#"> Actions
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li>Edit Demographics</li>
<li>New Encounter</li>
<li>View Pastvotes</li>
</ul>
</div></td>
</tr>
<tr style="text-align:center;">
<td>Praveen jena</td>
<td>06-03-1991</td>
<td>Suffering From heart attack</td>
<td>12-04-2013</td>
<td>SJ</td>
<td><div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> Actions <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li>Action</li>
<li>Edit Demographics</li>
<li>New Encounter</li>
<li>View Pastvotes</li>
</ul>
</div>
</td>
</tr>
<tr style="text-align:center;">
<td>Sahil Sahoo</td>
<td>06-03-1991</td>
<td>Suffering From heart attack</td>
<td>12-04-2013</td>
<td>SJ</td>
<td><div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> Actions <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li>Action</li>
<li>Edit Demographics</li>
<li>New Encounter</li>
<li>View Pastvotes</li>
</ul>
</div>
</td>
</tr>
<tr style="text-align:center;">
<td>Akash Pattnaik</td>
<td>06-03-1991</td>
<td>Suffering From heart attack</td>
<td>12-04-2013</td>
<td>SJ</td>
<td><div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> Actions <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li>Action</li>
<li>Edit Demographics</li>
<li>New Encounter</li>
<li>View Pastvotes</li>
</ul>
</div>
</td>
</tr>
<tr style="text-align:center;">
<td>Sheetam kumar jena</td>
<td>06-03-1991</td>
<td>Suffering From heart attack</td>
<td>12-04-2013</td>
<td>SJ</td>
<td><div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> Actions <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li>Action</li>
<li>Edit Demographics</li>
<li>New Encounter</li>
<li>View Pastvotes</li>
</ul>
</div>
</td>
</tr>
</table>-->
</td>
</tr>
</table>
<table align="right" border="0">
<TR align="right">
<TD><form action="clinic_p.html">
<input type="submit" class="btn btn-success" value="Add Patient">
</form></TD></TR>
</table>
</div>
</div>
</div>
<div style="background-color:#1d719a; height:80px; margin-top:20px;">
<div style="width:40%; font:Verdana, Geneva, sans-serif; font-size:14px; font-weight:bold; color:#FFF;">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%;">
<tr><td style="height:20px;" colspan="2"> </td></tr>
<tr><td style="width:5%"> </td><td>Copyrights 2013. All Rights Reserved.</td></tr>
</table></div>
<div style="width:40%; float:right; text-align:right; margin:-40px 30px 0px 0px;font:Verdana, Geneva, sans-serif; font-size:14px; font-weight:bold; color:#FFF;">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%;">
<tr><td style="height:20px;" colspan="2"> </td></tr>
<tr><td style="width:5%"> </td><td>Monyter Technologies Pvt. Ltd.</td></tr>
</table>
</div>
</div>
</body>
</html>
Any solutions will be great.
for making responsive table i usually use another style not of bootstrap
<style>
#page-wrap {
margin: 50px;
}
p {
margin: 20px 0;
}
/*
Generic Styling, for Desktops/Laptops
*/
table {
width: 100%;
border-collapse: collapse;
}
/* Zebra striping */
tr:nth-of-type(odd) {
background: #eee;
}
th {
background: #333;
color: white;
font-weight: bold;
}
td, th {
padding: 6px;
border: 1px solid #ccc;
text-align: left;
}
</style>
<!--[if !IE]><!-->
<style>
/*
Max width before this PARTICULAR table gets nasty
This query will take effect for any screen smaller than 760px
and also iPads specifically.
*/
#media
only screen and (max-width: 760px),
(min-device-width: 768px) and (max-device-width: 1024px) {
/* Force table to not be like tables anymore */
table, thead, tbody, th, td, tr {
display: block;
}
/* Hide table headers (but not display: none;, for accessibility) */
thead tr {
position: absolute;
top: -9999px;
left: -9999px;
}
tr { border: 1px solid #ccc; }
td {
/* Behave like a "row" */
border: none;
border-bottom: 1px solid #eee;
position: relative;
padding-left: 50%;
}
td:before {
/* Now like a table header */
position: absolute;
/* Top/left values mimic padding */
top: 6px;
left: 6px;
width: 45%;
padding-right: 10px;
white-space: nowrap;
}
/*
Label the data
*/
td:nth-of-type(1):before { content: "First Name"; }
td:nth-of-type(2):before { content: "Last Name"; }
td:nth-of-type(3):before { content: "Job Title"; }
td:nth-of-type(4):before { content: "Favorite Color"; }
td:nth-of-type(5):before { content: "Wars of Trek?"; }
td:nth-of-type(6):before { content: "Porn Name"; }
td:nth-of-type(7):before { content: "Date of Birth"; }
td:nth-of-type(8):before { content: "Dream Vacation City"; }
td:nth-of-type(9):before { content: "GPA"; }
td:nth-of-type(10):before { content: "Arbitrary Data"; }
}
/* Smartphones (portrait and landscape) ----------- */
#media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
body {
padding: 0;
margin: 0;
width: 320px; }
}
/* iPads (portrait and landscape) ----------- */
#media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {
body {
width: 495px;
}
}
</style>
<!--<![endif]-->
and html
<div id="page-wrap">
<table>
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Job Title</th>
<th>Favorite Color</th>
<th>Wars or Trek?</th>
<th>Porn Name</th>
<th>Date of Birth</th>
<th>Dream Vacation City</th>
<th>GPA</th>
<th>Arbitrary Data</th>
</tr>
</thead>
<tbody>
<tr>
<td>James</td>
<td>Matman</td>
<td>Chief Sandwich Eater</td>
<td>Lettuce Green</td>
<td>Trek</td>
<td>Digby Green</td>
<td>January 13, 1979</td>
<td>Gotham City</td>
<td>3.1</td>
<td>RBX-12</td>
</tr>
<tr>
<td>The</td>
<td>Tick</td>
<td>Crimefighter Sorta</td>
<td>Blue</td>
<td>Wars</td>
<td>John Smith</td>
<td>July 19, 1968</td>
<td>Athens</td>
<td>N/A</td>
<td>Edlund, Ben (July 1996).</td>
</tr>
<tr>
<td>Jokey</td>
<td>Smurf</td>
<td>Giving Exploding Presents</td>
<td>Smurflow</td>
<td>Smurf</td>
<td>Smurflane Smurfmutt</td>
<td>Smurfuary Smurfteenth, 1945</td>
<td>New Smurf City</td>
<td>4.Smurf</td>
<td>One</td>
</tr>
<tr>
<td>Cindy</td>
<td>Beyler</td>
<td>Sales Representative</td>
<td>Red</td>
<td>Wars</td>
<td>Lori Quivey</td>
<td>July 5, 1956</td>
<td>Paris</td>
<td>3.4</td>
<td>3451</td>
</tr>
<tr>
<td>Captain</td>
<td>Cool</td>
<td>Tree Crusher</td>
<td>Blue</td>
<td>Wars</td>
<td>Steve 42nd</td>
<td>December 13, 1982</td>
<td>Las Vegas</td>
<td>1.9</td>
<td>Under the couch</td>
</tr>
</tbody>
</table>
</div>
hope this will work for you
If you were using foundation you could use http://zurb.com/playground/responsive-tables
But, you're not...so...
No my real reason here is to say, tables, normally aren't responsive. They do change to an extent, but they also have a minimum width. After they get so small, they just wont break.
Perhaps though, you could alter the responsive table code to work with bootstrap though.
Here's a perfect thread for you::
How to display tables on mobile using Bootstrap?
You might want to migrate to Bootstrap 3 as it now supports responsive tables to some extent: http://getbootstrap.com/css/#tables-responsive.
If so, you should be good by adding a <div class="table-responsive"> around your <table>.
Also http://bootply.com/bootstrap-3-migration-guide is quite helpful to migrate to Bootstrap 3.
Related
I am stuck in a simple problem , am not able to view my table responsive in mobile view
can anyone tell me how can I make it responsive in mobile view, please tell me, if you have any question related my problem please free fell to ask
tabel.html
This is my table where I want to make responsive i am using bootstrap framework for making a table.
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css"
integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin="anonymous" />
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght#600&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.0/dist/css/bootstrap.min.css"
integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
<title>about Web</title>
</head>
<body>
<!-- Navbar Start -->
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top" style="background-color: #cadefc !important; color:#798777;">
<div class="container">
<a class="navbar-brand" href="index.html">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation" style="border: none;">
<i class="fas fa-bars"></i>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item ">
<a class="nav-link" href="index.html">Home </a>
</li>
<li class="nav-item">
<a class="nav-link" href="index.html">Service</a>
</li>
<li class="nav-item">
<a class="nav-link" href="about.html">About Us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="price.html">Price</a>
</li>
<li class="nav-item">
<a class="nav-link" href="team.html">Our Team</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contact.html">Contact Us</a>
</li>
</ul>
</div>
</div>
</nav>
<!-- Navbar End -->
<!-- Price section Start -->
<section class="price mb-5" style="margin-top: 100px;" style=" overflow-x: scroll-bar; height:200px;">
<div class="container table-responsive" >
<table class="table table-bordered" style="width: 100%;">
<thead class="thead-light">
<tr>
<th scope="col">Package</th>
<th scope="col">Static</th>
<th scope="col">Intermediate</th>
<th scope="col">Dynamic</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row ">Price</th>
<td style="background-color: lightskyblue;"><i class="fas fa-rupee-sign"></i> </td>
<td style="background-color: lightgreen;"><i class="fas fa-rupee-sign"></i> </td>
<td style="background-color: lightcoral;"><i class="fas fa-rupee-sign"></i> </td>
</tr>
<tr>
<th scope="row">No of Pages</th>
<td>4</td>
<td>6</td>
<td>12</td>
</tr>
<tr>
<th scope="row">Mobile Tablet Friendly</th>
<td><i class="far fa-check"></i></td>
<td><i class="far fa-check"></i></td>
<td><i class="far fa-check"></i></td>
</tr>
<tr>
<th scope="row">Inquiry Page</th>
<td>-</td>
<td><i class="far fa-check"></i></td>
<td><i class="far fa-check"></i></td>
</tr>
<tr>
<th scope="row">Design Quality</th>
<td style="color: gray;">Basic</td>
<td style="color: gray;">Intermediate</td>
<td style="color: gray;">Creative</td>
</tr>
<tr>
<th scope="row">Social Media Link Integration</th>
<td>-</td>
<td>-</td>
<td><i class="far fa-check"></i></td>
</tr>
<tr>
<th scope="row">Whatsapp Integration</th>
<td>-</td>
<td>-</td>
<td><i class="far fa-check"></i></td>
</tr>
<tr>
<th scope="row">Extra pages</th>
<td style="color: gray;">Rs 200 for Each page</td>
<td style="color: gray;">Rs 300 for Each page</td>
<td style="color: gray;">-</td>
</tr>
<tr>
<th scope="row">Time Period</th>
<td style="color: gray;">4 days</td>
<td style="color: gray;">7 days</td>
<td style="color: gray;">negotiation</td>
</tr>
<tr>
<th scope="row"></th>
<td><a href="https://ashish-45.github.io/static-serviceWebsite/#"><button
class="btn btn-primary">View Sample</button></a></td>
<td><a href="https://ashish-45.github.io/SimpleDynamic/"><button class="btn btn-success">View
Sample</button></a></td>
<td><a href="https://ashish-45.github.io/static-serviceWebsite/#"><button
class="btn btn-danger">View Sample</button></a></td>
</tr>
</tbody>
</table>
</div>
</section>
<!-- price section end -->
<!-- end -->
<!-- footer start -->
<div class="footer bg-dark">
<p class="text-center text-white mb-3 p-3">© 2021 abc solution All rights reserved.</p>
</div>
<!-- footer end -->
<script src="index.js"></script>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.1/dist/umd/popper.min.js"
integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#4.6.0/dist/js/bootstrap.min.js"
integrity="sha384-+YQ4JLhjyBLPDQt//I+STsc9iw4uQqACwlvpslubQzn4u2UU2UFM80nGisd026JF"
crossorigin="anonymous"></script>
</body>
</html>
https://codepen.io/geoffyuen/pen/FCBEg
.rwd-table {
margin: 1em 0;
min-width: 300px;
}
.rwd-table tr {
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
}
.rwd-table th {
display: none;
}
.rwd-table td {
display: block;
}
.rwd-table td:first-child {
padding-top: .5em;
}
.rwd-table td:last-child {
padding-bottom: .5em;
}
.rwd-table td:before {
content: attr(data-th) ": ";
font-weight: bold;
width: 6.5em;
display: inline-block;
}
#media (min-width: 480px) {
.rwd-table td:before {
display: none;
}
}
.rwd-table th, .rwd-table td {
text-align: left;
}
#media (min-width: 480px) {
.rwd-table th, .rwd-table td {
display: table-cell;
padding: .25em .5em;
}
.rwd-table th:first-child, .rwd-table td:first-child {
padding-left: 0;
}
.rwd-table th:last-child, .rwd-table td:last-child {
padding-right: 0;
}
}
body {
padding: 0 2em;
font-family: Montserrat, sans-serif;
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
color: #444;
background: #eee;
}
h1 {
font-weight: normal;
letter-spacing: -1px;
color: #34495E;
}
.rwd-table {
background: #34495E;
color: #fff;
border-radius: .4em;
overflow: hidden;
}
.rwd-table tr {
border-color: #46637f;
}
.rwd-table th, .rwd-table td {
margin: .5em 1em;
}
#media (min-width: 480px) {
.rwd-table th, .rwd-table td {
padding: 1em !important;
}
}
.rwd-table th, .rwd-table td:before {
color: #dd5;
}
This is a great pen for a responsive table, in most cases tables are not responsive. The media query looks at the size of the device and will display it as a block or none.
In most cases tables are not responsive friendly because of cell content and number of columns is big. So in those cases scrollbar at bottom is fine. But in your case you have only 4 columns - so you can use mediaquery in css and decrease font-sizes and th, td cells paddings and button sizes for mobile resolutions. Or use bootstrap classes for lower device resolutions.
Also please read rules and include code runner in question. Its not convenient to copy-paste and check on local.
I have a table on my site. When I add position:fixed to the table, the cells of the table suddenly stretch across the entire height of the page, even though they have a set height.
as you can see in the code below, each tr has a set height value, but it is ignored when I add position:fixed to the table, and instead, the cells get the height of the entire page, and prevent me from accessing the content of the website.
any help on how to fix this, while still keeping the position:fixed attribute, would be appreciated.
.center {
margin:0 auto;
}
a{
text-decoration:none;
color:red;
}
table{
text-align:center;
width:30%;
left:25%;
/*font-size:larger;*/
}
body{
background-color:midnightblue;
color:snow;
white-space:nowrap;
}
.Error{
color:red;
}
.divSargel{
width:initial;
background-color:snow;
border: solid;
border-color: #000080;
float: left;
margin-left: 0.3%;
color: red;
font-size:x-large;
font-family:monospace;
border-radius: 20px;
text-align: center;
width:100%;
}
.divSargel:hover {
background-color: blue;
transition: linear 0.5s;
}
<table id="navbar" border="1" style="right:0px;left:0px;border-style: solid;border-color:black;margin:0 auto;max-width:999999px; width:100%; height: 100%; background-image: none;">
<tr>
<td colspan="5" style="background-image: url('/Pics/videogames2.jpg'); height:100px; background-repeat: no-repeat; background-size:100% 100%">
</td>
</tr>
<tr style="height:50px">
<td style="border-color: #000000; background-color: #000000; color: #FFFFFF;">
<asp:TextBox ID="txtClock" style="text-align:center" runat="server" width="90%" ReadOnly="true"></asp:TextBox>
</td>
<td style="border-color: #000000; color: #FFFFFF; background-color: #000000">
<asp:TextBox ID="txtPeopleCount" style="text-align:center" runat="server" Width="90%" ReadOnly="true"></asp:TextBox>
</td>
<td style="width:50%;border:medium solid #000080; background-color: #000000;">
<table border="1" style="border-color:snow;width:100%">
<%if (Session["UserName"] == null)
{ %>
<tr>
<td class="textCenter">
<a href="Main.aspx" class="divSargel">
Main
</a>
</td>
<td class="textCenter">
<a href="ShopProducts.aspx" class="divSargel">
Shop
</a>
</td>
</tr>
<%} %>
<%if (Session["UserName"] != null && Session["UserAdmin"] == null)
{ %>
<tr>
<td class="textCenter">
<a href="Main.aspx" class="divSargel">
Main
</a>
</td>
<td class="textCenter" >
<a href="ShowUsers.aspx" class="divSargel">
Show Users
</a>
</td>
<td class="textCenter">
<a href="ShopProducts.aspx" class="divSargel">
Shop
</a>
</td>
<td class="textCenter">
<a href="ShoppingCart.aspx" class="divSargel">
View Cart
</a>
</td>
</tr>
<tr>
<td class="textCenter">
<a href="ShowBank.aspx" class="divSargel">
View Bank
</a>
</td>
<td class="textCenter">
<a href="ShowCreditCards.aspx" class="divSargel">
View credit cards
</a>
</td>
<td class="textCenter">
<a href="ShowOrders.aspx" class="divSargel">
View Orders
</a>
</td>
<td class="textCenter">
<a href="ContactUs.aspx" class="divSargel">
Contact us
</a>
</td>
</tr>
<%} %>
<%if (Session["UserAdmin"] != null)
{ %>
<tr>
<td class="textCenter">
<a href="Main.aspx" class="divSargel">
Main
</a>
</td>
<td class="textCenter" >
<a href="ShowUsers.aspx" class="divSargel">
Show Users
</a>
</td>
<td class="textCenter">
<a href="ShopProducts.aspx" class="divSargel">
Shop
</a>
</td>
<td class="textCenter">
<a href="ShoppingCart.aspx" class="divSargel">
View Cart
</a>
</td>
</tr>
<tr>
<td class="textCenter">
<a href="ShowBank.aspx" class="divSargel">
View Bank
</a>
</td>
<td class="textCenter">
<a href="ShowCreditCards.aspx" class="divSargel">
View credit cards
</a>
</td>
<td class="textCenter">
<a href="ShowOrders.aspx" class="divSargel">
View Orders
</a>
</td>
<td class="textCenter">
<a href="AdminPage.aspx" class="divSargel">
Admin actions
</a>
</td>
</tr>
<%} %></table>
</td>
<%if (Session["UserName"] == null)
{ %>
Try setting the height of the table as desired and mark it as important like
table{
height : 150px !important;
}
Managed to find the problem. for some reason I had a height:100% on the table itself, and so even though the rows had specified heights, upon adding position:fixed the table stretched across the screen.
I'm trying to do a responsive table but my table disappears in wide window and I can't understand why. My code is here, the line table responsive is commented so it works on wide screens and it is for me to see the table:
<!DOCKTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<title>WebHosting-Preços</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="main.css" type="text/css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<!--NavBar-->
<div class="row">
<div class="col-lg-8">
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">WebHosting</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li>Contactos</li>
<li>Preços</li>
</ul>
</div>
</div>
</nav>
</div>
</div><!--NavBar END-->
<div class="columns2">
<ul class="price">
<li class="header">Host</li>
<li class="grey">Free</li>
<li>Sem criação de WebSite</li>
<li>Sem Dominio</li>
<li class="grey"><a class="btn btn-primary btn-lg" href="precos" role="button">Buy Now</a></li>
</ul>
</div>
<div class="columns2">
<ul class="price">
<li class="header">Host + WebSite</li>
<li class="grey">€ 9.99</li>
<li>Criação do WebSite</li>
<li>Sem Dominio</li>
<li class="grey"><a class="btn btn-primary btn-lg" href="precos" role="button">Buy Now</a></li>
</ul>
</div>
<div class="columns2">
<ul class="price">
<li class="header">Host + WebSite + Dominio</li>
<li class="grey">€ 9.99 / year</li>
<li>Criação do WebSite</li>
<li>Dominio incluido</li>
<li class="grey"><a class="btn btn-primary btn-lg" href="precos" role="button">Buy Now</a></li>
</ul>
</div>
<div class="table-responsive">
<table class="table table-bordered">
<tr>
<th>Serviço</th>
<th>Descrição</th>
</tr>
<tr>
<td>Criação de website</td>
<td>A Empresa responsabiliza-se pela criação de um website a seu gosto</td>
</tr>
<tr>
<td>Dominio</td>
<td>A Empresa responsabiliza-se pela compra e manutenção do Dominio escolhido pelo utilizador</td>
</tr>
</table>
</div>
</body>
</html>
CSS
body {
margin: 0;
}
.jumbotron{
align-items:center;
display:flex;
background-image:url('https://static.pexels.com/photos/392018/pexels-photo-392018.jpeg');
background-size:cover;
height:450px;
color:white;
height: 50vh;
}
* {
box-sizing: border-box;
}
.columns {
float: left;
width: 33.3%;
padding: 8px;
}
.columns2 {
float: left;
width: 33.3%;
padding-top: 70px;
}
.price {
list-style-type: none;
border: 1px solid #eee;
margin: 0;
padding: 0;
-webkit-transition: 0.3s;
transition: 0.3s;
}
.price:hover {
box-shadow: 0 8px 12px 0 rgba(0,0,0,0.2)
}
.price .header {
background-color: #2D2727;
color: white;
font-size: 25px;
}
.price li {
border-bottom: 1px solid #eee;
padding: 20px;
text-align: center;
}
.price .grey {
background-color: #eee;
font-size: 20px;
}
.button {
background-color: #4CAF50;
border: none;
color: white;
padding: 10px 25px;
text-align: center;
text-decoration: none;
font-size: 18px;
}
#media only screen and (max-width: 600px) {
.columns {
width: 100%;
}
}
.table{
color: black;
text-align:center;
}
.table th{
text-align:center;
}
it might be helpful.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<div class="container">
<h2>Table</h2>
<p>The .table-responsive class creates a responsive table which will scroll horizontally on small devices (under 768px). When viewing on anything larger than 768px wide, there is no difference:</p>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
<th>City</th>
<th>Country</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Anna</td>
<td>Pitt</td>
<td>35</td>
<td>New York</td>
<td>USA</td>
</tr>
</tbody>
</table>
</div>
</div>
May be .table-responsive class inherit or override in your css or any other css/library override it.
But I tried below example with table-responsive class it is working fine.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
<th>Column 4</th>
<th>Column 5</th>
</tr>
</thead>
<tbody>
<tr>
<td>test1</td>
<td>test2</td>
<td>test3</td>
<td>324</td>
<td>123</td>
<td>000</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>
The problem with this is that on this part:
<div class="container">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>Serviços</th>
<th>Descrição</th>
</tr>
</thead>
<tbody>
<tr>
<td>test1</td>
<td>test2</td>
</tr>
</tbody>
</table>
</div>
</div>
It only says the table to be responsive and not both a normal table and a responsive table, in order to change it I needed to do this:
<div class="table table-responsive">
instead of
<div class="table-responsive">
Add <div class="clearfix"></div> just above your table HTML, CSS of elements above your table code is inhering its properties to the table elements
I'm trying to position a Bootstrap styled dropdown button for use with a table. I can get it so the container rows butt up, but then there is a visual gap between the button and the edge of the table. I'm trying to shrink that gap (to maybe 3 px?).
I've messed with absolute and relative positioning, but for some reason my brain just isn't getting it.
I quick put together this fiddle to help shown what I mean: https://jsfiddle.net/rbennett/emup7wpe/1/
<div class="container">
<div class="col-sm-12">
Trying to figure out how to correctly position a button for a table...
<br />
<br />
<div class="button-row">
<button id="itemsButton" type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
Items<span class="caret"></span>
</button>
<ul id="itemSelectorDropdown" class="dropdown-menu">
<li>test1</li>
<li>test2</li>
<li>test3</li>
</ul>
</div>
<br />
<div class="other-row">
<table id="testTable" class="table table-bordered" cellspacing="0">
I have elements from a DatatTable table that sit right here<br />so I'm looking to position the "Items" button on the same line,<br />but aligned to the right.
<thead>
<tr>
<th>Data1</th>
<th>Data2</th>
</tr>
</thead>
<tbody>
<tr>
<td>xyz</td>
<td>abc</td>
</tr>
<tr>
<td>qrs</td>
<td>123</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
Can someone nudge me in the right direction on how to position the button so that it is right above the table (and not have a gap)?
I modified your html just a tiny bit. I moved the button just above the table.
I also added 1 rule to move the button.
.other-row {
outline: 1px solid blue;
}
#itemsButton{
float: right;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="col-sm-12">
Trying to figure out how to correclty position a button...
<br />
<br />
<div class="button-row">
<ul id="itemSelectorDropdown" class="dropdown-menu">
<li>test1</li>
<li>test2</li>
<li>test3</li>
</ul>
</div>
<br />
<div class="other-row">
<button id="itemsButton" type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">Items<span class="caret"></span></button>
<table id="testTable" class="table table-bordered" cellspacing="0">
We want to see the "Items" button here (aligned to the right)
<thead>
<tr>
<th>Data1</th>
<th>Data2</th>
</tr>
</thead>
<tbody>
<tr>
<td>xyz</td>
<td>abc</td>
</tr>
<tr>
<td>qrs</td>
<td>123</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
just change border-radius:0 in your button
#itemsButton
{border-radius:0;float:right;}
.other-row {
outline: 1px solid blue;
}
#itemsButton
{border-radius:0; float:right}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<div class="col-sm-12">
Trying to figure out how to correclty position a button...
<br />
<br />
<div class="other-row">
<div class="button-row">
<button id="itemsButton" type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
Items<span class="caret"></span>
</button>
<ul id="itemSelectorDropdown" class="dropdown-menu">
<li>test1</li>
<li>test2</li>
<li>test3</li>
</ul>
</div>
<table id="testTable" class="table table-bordered" cellspacing="0">
<thead>
<tr>
<th>Data1</th>
<th>Data2</th>
</tr>
</thead>
<tbody>
<tr>
<td>xyz</td>
<td>abc</td>
</tr>
<tr>
<td>qrs</td>
<td>123</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
I found a solution on how to fixed a table with scroll bar by creating another class .tablecontainer, but in this case I need to add a drop-down list on one column so my table adjusted its height according to the drop-down cell column, I need to adjust all rows, according to drop-down cell's height.
A screenshot of the state is:
This is my code:
<head>
<style type="text/css">
table {
table-layout: fixed;
word-wrap: break-word;
vertical-align: central;
}
.tablecontainer {
width: 1000px;
overflow: hidden;
}
tr {
display: block;
}
th, td {
width: 500 px;
}
tbody {
display: block;
height: 400px;
overflow: auto;
}
.table tbody > tr > td.vert-align {
vertical-align: middle;
}
</style>
</head>
<body>
and HTML:
<div class="container" style="padding: 70px">
<h3 style="font-family:'Century Gothic'"></h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th style= "column-width:100px; text-align:center">Employee No.</th>
<th style= "column-width:200px; text-align:center">Employee Name</th>
<th style= "column-width:100px; text-align:center"">Status</th>
<th style= "column-width:100px; text-align:center"">Training Title</th>
<th style= "column-width:100px; text-align:center"">Action</th>
</tr>
</thead>
<tbody>
<tr>
<td style= "column-width:100px; celltext-align:center">12345</td>
<td style= "column-width:200px; text-align:center">Lardino, Bryan S.</td>
<td style= "column-width:100px; text-align:center">For Approval</td>
<td style= "column-width:100px; text-align:center">Wave Training</td>
<td style= "column-width:100px; text-align:center"><div class="btn-group">
<button type="button" class="btn btn-default">Action</button>
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
<li>Approved</li>
<li>Disapproved</li>
</ul>
</div></td>
</tr>
<tr>
<td style= "column-width:100px; text-align:center">12345</td>
<td style= "column-width:200px; text-align:center">Lardino, Bryan S.</td>
<td style= "column-width:100px; text-align:center">For Approval</td>
<td style= "column-width:100px; text-align:center">Wave Training</td>
<td style= "column-width:100px; text-align:center"><div class="btn-group">
<button type="button" class="btn btn-default">Action</button>
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
<li>Approved</li>
<li>Disapproved</li>
</ul>
</div></td>
</tr>
</tbody>
</table>
<div class="row" style="height: 50px">
<a class="btn btn-primary btn-default pull-right" href="#")>Submit</a>
</div>
</div>
</body>