Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
When it is in the normal screen size, all looks fine. when minimizing the screen, the table's titles could not be seen.

<html lang="en">
	<head>
		<meta charset = "UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta http-equiv="X-UA-Compatible" content="ie-edge">
		<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
	<style>
			body {
				padding: 0;
				margin: 0;
				font-family: Verdana, sans-serif;
			}
			.container {
				position: relative;
				margin-top: 120px;
				width: 50%;
				//height: 50%;
			}
			.container img {
				display: block;
				width: 100%;
			}
			nav {
				position: fixed;
				z-index: 10;
				left: 0;
				right: 0;
				top: 0;
				font-family: 'Montserrat', sans-serif;
				padding: 0 5%;
				height: 100px;
				background-color: #3e65da;
			}
			nav .logo {
				float: left;
				width: 40%;
				height: 100%;
				display: flex;
				align-items: center;
				font-size: 24px;
				color: #fff;
			}
			nav .links {
				float: right;
				padding: 0;
				margin: 0;
				width: 60%;
				height: 100%;
				display: flex;
				justify-content: space-around;
				align-items: center;
			}
			nav .links li {
				list-style: none;
			}
			nav .links a {
				display: block;
				padding: 1em;
				font-size: 16px;
				font-weight: bold;
				color: #fff;
				text-decoration: none;
			}
			#nav-toggle {
				position: absolute;
				top: -100px;
			}
			nav .icon-burger {
				display: none;
				position: absolute;
				right: 5%;
				top: 50%;
				transform: translateY(-50%);
			}
			nav .icon-burger .line {
				width: 30px;
				height: 5px;
				background-color: #fff;
				margin: 5px;
				border-radius: 3px;
				transition: all .3s ease-in-out;
			}
			@media screen and (max-width: 768px) {
				.container {
					position: relative;
					margin-top: 120px;
					width: 100%;
					//height: 100%;
				}
				.container img {
					display: block;
					width: 100%;
				}
				nav .logo {
					float: none;
					width: auto;
					justify-content: center;
				}
				nav .links {
					float: none;
					position: fixed;
					z-index: 9;
					left: 0;
					right: 0;
					top: 100px;
					bottom: 100%;
					width: auto;
					height: auto;
					flex-direction: column;
					justify-content: space-evenly;
					background-color: rgba(0,0,0,.8);
					overflow: hidden;
					box-sizing: border-box;
					transition: all .5s ease-in-out;
				}
				nav .links a {
					font-size: 20px;
				}
				nav :checked ~ .links {
					bottom: 0;
				}
				nav .icon-burger {
					display: block;
				}
				nav :checked ~ .icon-burger .line:nth-child(1) {
					transform: translateY(10px) rotate(225deg);
				}
				nav :checked ~ .icon-burger .line:nth-child(3) {
					transform: translateY(-10px) rotate(-225deg);
				}
				nav :checked ~ .icon-burger .line:nth-child(2) {
					opacity: 0;
				}	

				.smart-table thead{
					display: none;
				}

				.smart-table tr, .smart-table td{
					display: block;
				}

				.smart-table tr:not(:last-child){
					border-bottom: 5px solid #5ca0c3;
				}

				.smart-table td{
					padding-left:54%;
					position: relative;
				}

				.smart-table td::before{
					position: absolute;
					padding: 5px;
					left: 0;
					top: 0;
					bottom: 0;
					width: 45%;
					content: attr(data-col-title);
					font-weight: bold;
					background-color: #f3f7fa;
				}

				.myTable{
					//display:none;
					position: relative;
					//margin-top: 40px;
					width: 80%;
					//height: 60%;
					margin-right: auto;
					margin-left: auto;
					margin-bottom: 40px;
					align-items: center;
				}
			}

			@media (min-width: 1024px){
				.title{
					text-align:center;
				}

				table{
					width: 80%
				}
			}

			.myTable{
				//display:none;
				position: relative;
				margin-top: 30px;
				width: 80%;
				//height: 60%;
				margin-right: auto;
				margin-left: auto;
				align-items: center;
			}
			
			table{
				border-collapse: collapse;
				width: 100%;
				margin: 10px auto 0;
				font-size:  1rem;
				color: #4a788b;
				border-radius: 10px;
			}
			table thead{
				background-color: #d9f8fc;
			}
			table th, table td{
				border:1px solid #6fcfff;
				padding: 5px 10px;
			}

		</style>
		<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
    	<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.min.js"></script>
	</head>
	<body>
		<div class="myTable">
			<table class="smart-table">
			    <thead>
			      <tr>
			        <th>Name</th>
			        <th>Condition</th>
			        <th>Type of Oat</th>
			        <th>Quantity</th>
			        <th>Status</th>
			      </tr>
			    </thead>
			    <tbody>
			    	<tr>
			    		<?php
			    			$con = mysqli_connect("localhost","root","","oatdistribution");
							$tabsql = "SELECT Name, LivingCondition, OatType, NoOfOats, Status FROM OatDis"; 
							$data = mysqli_query($con,$tabsql);
							//$total = mysqli_num_rows($data);
							//$tabresult = mysqli_fetch_assoc($data); 
							while($row = mysqli_fetch_assoc($data)){
								echo "<tr>";
								echo "<td>" . $row['Name']."</td>";
								echo "<td>" . $row['LivingCondition']."</td>";
								echo "<td>" . $row['OatType']."</td>";
								echo "<td>" . $row['NoOfOats']."</td>";
								echo "<td>" . $row['Status']."</td>";
								echo "</tr>";
							}
						?>
			    	</tr>			    
			    </tbody>    
  			</table>
		</div>
		<div style= height:50%;></div>
	</body>
</html>


What I have tried:

I have tried adjusting the size but still no luck
Posted
Updated 23-Mar-21 23:49pm
Comments
Richard MacCutchan 24-Mar-21 4:34am    
Why would you expect to see them in a minimized app?

1 solution

It looks like you're not understanding your CSS. Have you just copied it from another website and applied it to your own screen?
CSS
@media screen and (max-width: 768px) {
  ..

  .smart-table thead{
    display: none;
  }

  ..
}

What this is saying is "when we are rendering for a screen and the view width is 768px or less: hide the thead element". If you want the header to stay then you need to remove the thead CSS style.

CSS @media Rule[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900