Gareth Hards
Gareth Hards

Reputation: 1

html table needs adjusting for different screens

I've got a table that looks okay and fit the screen and adjusts to a certain point and any smaller.

It doesn't display completely and shows the right hand size of the table.

I really don't want to change the table settings with the style in the html code, as they look right but do need to add something there to make it change to be underneath Ie.the <th> needs to have an extra <tr> then the <th> to get it underneath each other.

function openNav() {
  document.getElementById("mySidenav").style.width = "100%";
}

function closeNav() {
  document.getElementById("mySidenav").style.width = "0";
}
h1 {
  font-size: 18.5px;
  font-weight: 200;
  align: center;
  font-style: italic;
  color: #fff;
  padding: .8rem .8rem .8rem .8rem;
  border: 0.2rem solid #fff;
  border-radius: 1rem;
  text-transform: uppercase;
  animation: flicker 1.5s infinite alternate;
}

h1::-moz-selection {
  background-color: var(--neon-border-color);
  color: var(--neon-text-color);
}

h1::selection {
  background-color: var(--neon-border-color);
  color: var(--neon-text-color);
}

h1:focus {
  outline: none;
}


/* Animate neon flicker */

@keyframes flicker {
  0%,
  19%,
  21%,
  23%,
  25%,
  54%,
  56%,
  100% {
    text-shadow: -0.2rem -0.2rem 1rem #fff, 0.2rem 0.2rem 1rem #fff, 0 0 .5rem var(--neon-text-color), 0 0 .2rem var(--neon-text-color), 0 0 .2rem var(--neon-text-color), 0 0 .3rem var(--neon-text-color), 0 0 .3rem var(--neon-text-color);
    box-shadow: 0 0 .4rem #fff, inset 0 0 .3rem #fff, 0 0 3rem var(--neon-border-color), inset 0 0 2rem var(--neon-border-color), 0 0 1rem var(--neon-border-color), inset 0 0 2rem var(--neon-border-color);
  }
  14%,
  24%,
  55% {
    text-shadow: none;
    box-shadow: none;
  }
  hr {
    width: 100%;
    height: 6px;
    background-color: black;
    opcaity: 0.5;
    margin-left: auto;
    margin-right: auto;
    z-index: 400;
    margin-top: 0px;
    box-shadow: 0 0 10px 1px black;
  }
  .navigationtablex tr:nth-child(odd) {
    background-color: beige;
    min-width: 200px;
  }
  .navigationtablex tr:nth-child(even) {
    background-color: beige;
    min-width: 200px;
  }
  .navigationtablex tr {
    min-width: 200px;
  }
  .navigationtablex th:first-child,
  .navigationtablex td:first-child {
    padding: 0px;
    min-width: 200px;
  }
  .navigationtablex td,
  .navigationtablex th {
    padding: 0px;
    display: table-cell;
    text-align: left;
    vertical-align: top;
    min-width: 200px;
  }
  .navigationtablex th {
    font-weight: 400;
    min-width: 200px;
  }
  .navigationtablex {
    font-size: 18px!important;
    border: 3px solid #033;
    border-collapse: collapse;
    border-spacing: 3;
    min-width: 200px;
    display: table;
    float: right;
  }
  .dropbtn {
    padding: 0px;
    text-decoration: none;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
    color: black;
    font-weight: 500;
    height: 100%;
    text-shadow: 0px 0px yellow;
    text-align: center;
    vertical-align: top;
    font-size: 16.5px;
    border: none;
    letter-spacing: .7px;
    font-family: verdana;
    float: left;
    min-width: 2 px;
    align: left;
  }
  .dropbtn:hover {
    border: none;
    height: 100%;
  }
  .dropdown {
    position: relative;
    display: inline-block;
    min-width: 250px;
    padding: 0px;
    height: 100%;
    border: none;
    cursor: pointer;
  }
  .dropdown-content {
    display: none;
    position: absolute;
    background-image: linear-gradient(74.9deg, rgba(104, 13, 55, 1) 2.7%, rgba(122, 76, 244, 1) 68.6%, rgba(104, 13, 55, 1) 95%);
    min-width: 250px;
    box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
    z-index: 2;
    border: .5px solid #353D30;
    font-weight: bold;
    text-decoration: none;
    padding: 10px 6px 10px 6px;
    max-height: 400px;
    overflow: auto;
  }
  .dropdown-content a {
    color: black;
    padding: 10px 6px 10px 6px;
    text-decoration: none;
    z-index: 3;
    background-color: white;
    box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
    display: block;
    border: 2px solid #353D30;
    font-weight: 400;
    min-width: 250px;
    margin-right: 20px;
    margin-left: 2px;
  }
  .dropdown-content a:hover {
    background-color: #fff5ee;
    min-width: 2px;
    margin-right: 0px;
    display: block;
    border: 2px solid olive;
  }
  .dropdown:hover .dropdown-content {
    display: block;
    min-width: 2px;
    margin-right: 0px;
    color: black;
    font-weight: 400;
    border: none;
  }
  .dropdown:hover {
    background-color: beige;
    margin-right: 0px;
    border: none;
  }
  .columnb {
    float: left;
    width: 100%;
    padding: 15px 15px 15px 15px;
    min-height: 409px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
  }
  .columnc1 {
    float: left;
    width: 100%;
    padding: 15px 15px 15px 15px;
    height: 80px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
  }
  .sidenav {
    height: 100%;
    width: 0;
    position: fixed;
    z-index: 1;
    top: 0;
    left: 0;
    background-color: white;
    overflow-x: hidden;
    transition: 0.5s;
    padding-top: 60px;
    text-align: left;
  }
  .sidenav a {
    padding: 8px 8px 8px 8px;
    text-decoration: none;
    font-size: 25px;
    color: #818181;
    display: block;
    transition: 0.3s;
  }
  .sidenav a:hover {
    color: #f1f1f1;
  }
  .sidenav_a {
    height: 100%;
    width: 0;
    position: fixed;
    z-index: 1;
    top: 0;
    left: 0;
    background-color: white;
    overflow-x: hidden;
    transition: 0.5s;
    padding-top: 60px;
    text-align: left;
  }
  .sidenav_ a {
    padding: 8px 8px 8px 8px;
    text-decoration: none;
    font-size: 25px;
    color: blue;
    display: block;
    transition: 0.3s;
  }
  .sidenav_a a:hover {
    color: red;
  }
  .sidenav .closebtn {
    position: absolute;
    top: 0;
    right: 25px;
    font-size: 46px;
    margin-left: 50px;
  }
  .sidenav_a .closebtn_a {
    position: absolute;
    top: 0;
    right: 25px;
    font-size: 46px;
    margin-left: 50px;
  }
  .sidenav.closebtn_a {
    position: absolute;
    top: 0;
    right: 25px;
    font-size: 46px;
    margin-left: 50px;
  }
  @media screen and (max-height:450px) {
    .sidenav {
      padding-top: 15px;
    }
    .sidenav a {
      font-size: 17.5px;
    }
  }
<head>
  <meta http-equiv="imagetoolbar" content="no" />
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <title>GHDistribution NPC</title>
  <link href="https://fonts.googleapis.com/css2?family=Fredericka+the+Great&display=swap" rel="stylesheet">
  <script src="myjs.js"></script>
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous" />
  <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css" />
</head>

<body>
  <table class="navigationtablex" style="height:100%;min-width:100%;margin-left:0px;border:none;border-bottom:1px solid white;border-top:.5px solid #353D30;">
    <tr style="border:none;">
      <th style="background-image: linear-gradient(74.9deg, rgba(104,13,55,1) 2.7%, rgba(122,76,244,1) 68.6%, rgba(104,13,55,1) 95% );opcaity: 0.5;margin-left: auto;margin-right: auto;margin-top: 0px;box-shadow: 0 0 0px 1px #808000;">
        <table class="navigationtablex" style="height:100%;min-width:1%;margin-left:0px;border:none;float:left;">
          <tr style="border:none;height:100%;">
            <th style="padding:1px;height:100%;">
              <div class="dropdown" style="border:2px solid olive;height:100%;"><button class="dropbtn" style="height:100%;background:linear-gradient(to bottom, #ffcc99 0%, #ffffcc 100%);color:#003;font-weight:bold;font-size:15.5px;border:none;">Quick navigate</button>
                <div class="dropdown-content" style="min-height:1%;min-width:1%;"><a href="home_main.html">Home page </a><a href="about_main.html">About us </a><a href="about_wikipedia_descriptions.html">Wikipedia descriptions</a><a href="home_navigational_help.html">Navigational help</a><a href="home_projects.html">Projects</a>
                  <a href="about_social_pages.html">Social pages</a><a href="home_Sitemap.html">Site map </a><a href="home_Learning_platform.html">Learning platform </a><a href="email_fcp.html">Email us </a></div>
              </div>
            </th>
          </tr>
        </table>
        <hr style="border:none;border-top:1px solid #033;height:5px;background-image: linear-gradient(to right top, #4b3599, #c41881, #fc4a46, #f29f00, #a8eb12);opcaity: 0.5;margin-left: auto;margin-right: auto;margin-top: 0px;box-shadow: 0 0 0px 1px #808000;">
      </th>
    </tr>
  </table>
  <table class="navigationtable">
    <tr style="border:none;width:100%;">
      <th style="background-color:maroon;border: 0px solid pink; border:box-shadow: 0px 19px 13px 0px rgba(0,0,0,0.2);padding: 0px;width:100%;box-shadow: 0px 19px 13px 0px rgba(0,0,0,0.2)">
        <a name="about_heading_1"></a>
        <div class="row" style="padding:0px 0px 0px 0px;background-color:beige;border:0px solid white;width:100%;">
          <div class="columnc1" style="background-color:beige;border:0px solid white;padding:0px 0px 0px 0px;height:100%;width:100%;">
            <table class="navigationtable" style="width:100%;float:left;border:0px solid white;">
              <tr style="border:none;width:100%;">
                <th style="background:linear-gradient(to bottom, #ffcc99 0%, #ffffcc 100%);width:100%;">
                  <h2 style="text-align:left;margin-left:24px;margin-right:14px;margin-top:30px;margin-bottom:30px;text-shadow: 0px 0px black;letter-spacing: .7px;font-weight:bold;font-size:30.5px;color:#033;font-family: 'Fredericka the Great', cursive;">Information about our current situation.</h2>
                </th>
                <th style="min-height:0%;width:1%;padding:14px;margin:0px;background-color:white;">
                  <div class="columnb" style="background-color:black;border:1px solid white;min-height:0%;padding:1px;margin:0px;min-width:0%;">
                    <table class="navigationtablex" style="min-height:0%;min-width:0%;padding:0px;margin:0px;border:none;">
                      <tr style="border:none;min-height:0%;min-width:0%;padding:0px;margin:0px;">
                        <th style="padding:0px;margin:0px;min-height:0%;min-width:0%;">
                          <div class="dropdown" style="border:2px solid beige;min-height:0%;min-width:0%;padding:0px;margin:0px;">
                            <h2 style="font-size:29px;text-color:white;padding:10px;margin:3px;background-image: linear-gradient(to right top, #4b3599, #c41881, #fc4a46, #f29f00, #a8eb12);    pointer" onclick="openNav()">&#9776; </h2>
                          </div>
                        </th>
                      </tr>
                    </table>
                  </div>
                  <div id="mySidenav" class="sidenav"><a href="javascript:void(0)" class="closebtn" onclick="closeNav()">&times;</a></th>
                <th style="background-color:#0B3861;width:1%;padding:14px;">
                  <table class="navigationtablex" style="height:100%;min-width:1%;margin-left:0px;border:none;">
                    <tr style="border:none;height:100%;">
                      <th style="padding:1px;height:100%;">
                        <div class="dropdown" style="border:2px solid olive;height:100%;"><button class="dropbtn" style="height:100%;background:linear-gradient(to bottom, #ffcc99 0%, #ffffcc 100%);color:#003;font-weight:bold;font-size:15.5px;border:none;">Listed page headings</button>
                          <div class="dropdown-content" style="min-height:1%;min-width:1%;"><a href="#about_heading_1">Our current situation</a><a href="#about_heading_2">Wikipedia descriptions</a><a href="#about_heading_3">Fundraising</a><a href="#about_heading_4">Volunteering</a><a href="#about_heading_5">Study options</a>
                            <a href="#about_heading_6">Assistances and trainings</a><a href="#about_heading_7">Community based projects</a><a href="#about_heading_8">Enriching programs</a><a href="#about_heading_9">Public benefit organisations</a><a href="#about_heading_10">Unemployed people</a>
                            <a href="#about_heading_11">Business'es who support</a><a href="#about_heading_12">People who support</a></div>
                        </div>
                      </th>
                    </tr>
                  </table>
                  </div>
                </th>
                <th style="min-height:0%;width:1%;padding:14px;margin:0px;background-color:#0B4C5F;">
                  <div class="columnb" style="background-color:black;border:1px solid white;min-height:0%;padding:1px;margin:0px;min-width:0%;">
                    <table class="navigationtablex" style="min-height:0%;min-width:0%;padding:0px;margin:0px;border:none;">
                      <tr style="border:none;min-height:0%;min-width:0%;padding:0px;margin:0px;">
                        <th style="padding:0px;margin:0px;min-height:0%;min-width:0%;background:linear-gradient(to bottom, #ffcc99 0%, #ffffcc 100%);">
                          <div class="dropdown" style="border:2px solid beige;min-height:0%;min-width:0%;padding:0px;margin:0px;">
                            <h1><a href="about_current_situation.html" style="background-color:transparent;">&#9776;Open</a></h1>
                          </div>
                        </th>
                      </tr>
                    </table>
                  </div>
                </th>
              </tr>
              <hr>
            </table>&nbsp;</div>
        </div>
        <hr>
</body>

Upvotes: 0

Views: 85

Answers (1)

Shivam Puri
Shivam Puri

Reputation: 1666

Since there is no code to refer to in the question as of now, I can only suggest the following;

Look at the @media CSS rule (also called Media Query)

For example, if you want some specific styling in your table for devices with screen width less than 600px, you can use something like this;

@media only screen and (max-width: 600px){
    table {
        width : 100%;
    }
}

You can add this type of conditional styling to any html element and make your web page more responsive!

Upvotes: 1

Related Questions