Invisibility Problem

As a newcomer to web design, this is only the second website I have ever created. However, I am facing an issue with my Nav bar that I cannot seem to resolve. I want my "Other Pages" section to be visible when the screen size is below 600px and hidden when it exceeds that limit. The ul navbar should appear when the screen size is above 600px and disappear below that threshold.

I apologize for any strain on your eyes caused by this.

HTML

<ul>
  <li><a class="active" href="index.html">Home</a></li>
  <li><a href="html/aboutus.html">About Us</a></li>
  <li><a href="html/menu.html">Menu</a></li>
  <li><a href="html/zoo.html">Zoo</a></li>
<li><a href="html/parksandwalks.html">Parks and Walks</a></li>
    </ul>
</div>
<div class="navbar">
  <div class="dropdown">
    <button class="dropbtn">Other Pages
      <i class="fa fa-caret-down"></i>
    </button>
    <div class="dropdown-content">
      <a class="active" href="index.html">Home</a>
      <a href="../sunshine/html/aboutus.html">About Us</a>
      <a href="../sunshine/html/menu.html">Menu</a>
      <a href="../sunshine/html/zoo.html">Zoo</a>
      <a href="../sunshine/html/parksandwalks.html">Parks and Walks</a>
    </div>
  </div>
</div>

CSS

.menu ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
}

.menu li {
  padding: 8px;
  margin-bottom: 7px;
  background-color: #33b5e5;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}

.menu li:hover {
  background-color: #0099cc;
}

ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #333;
}

li {
  float: left;
}

li a {
  display: block;
  color: white;
  text-align: center;
  padding: 20px 150px;
  text-decoration: none;
}

li a:hover {
  background-color: #111;
}

@media only screen and (max-width: 600px) {
    [class*="col-6"] {
    width: 100%;
          }
}

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

@media only screen and (max-width: 600px) {
    li a {text-align: center;}
}

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

@media screen and (max-width: 600px) {
  .topnav a:not(:first-child) {display: none;}
  .topnav a.icon {
    float: right;
    display: block;
  }
}


@media screen and (max-width: 600px) {
  .topnav.responsive {position: relative;}
  .topnav.responsive a.icon {
    position: absolute;
    right: 0;
    top: 0;
  }
  
@media only screen and (max-width: 60px) {
  div.navbar {
    display: none;
  }
    
@media only screen and (max-width: 60px) {
  div.links {
    display: none;
  }   
} 

.topnav.responsive a {
    float: none;
    display: block;
    text-align: left;
  }
}

/* Navbar container */
.navbar {
  overflow: hidden;
  background-color: #333;
  font-family: Arial;
}

/* Links inside the navbar */
.navbar a {
  float: left;
  font-size: 16px;
  color: white;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
}

/* The dropdown container */
.dropdown {
  width: 100%;
  overflow: hidden;
  text-align: center
}

/* Dropdown button */
.dropdown .dropbtn {
  font-size: 16px;
  width: 100%;
  border: none;
  outline: none;
  color: white;
  padding: 14px 16px;
  background-color: inherit;
  font-family: inherit; /* Important for vertical align on mobile phones */
  margin: 0; /* Important for vertical align on mobile phones */
}

/* Add a red background color to navbar links on hover */
.navbar a:hover, .dropdown:hover .dropbtn {
  background-color: red;
}

/* Dropdown content (hidden by default) */
.dropdown-content {
  display: none;
  position: absolute;
  background-color: #f9f9f9;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
  z-index: 1;
}

/* Links inside the dropdown */
.dropdown-content a {
  float: none;
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  text-align: left;
}

/* Add a grey background color to dropdown links on hover */
.dropdown-content a:hover {
  background-color: #ddd;
}

/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
  display: block;
}

I deeply regret any discomfort caused to your eyes from viewing this code. Yes, I did gather most of this information from W3Schools.

Answer №1

why not give this a shot

ul {
  display:none;
  flex-wrap:wrap;
  list-style-type: none;
  margin: 0;
  padding: 0;
  background-color: #333;
}

li a {
  display: block;
  color: white;
  text-align: center;
  padding: 20px 150px;
  text-decoration: none;
}

li a:hover {
  background-color: #111;
}

.navbar {
  background-color: #333;
  font-family: Arial;
}

/* Dropdown content (hidden by default) */
.dropdown-content {
  display: none;
  background-color: #f9f9f9;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
}

/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
  display: block;
}

/* Links inside the navbar */
.navbar a {
  font-size: 16px;
  color: white;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
}

/* Dropdown button */
.dropdown .dropbtn {
  font-size: 16px;
  width: 100%;
  border: none;
  outline: none;
  color: white;
  padding: 14px 16px;
  background-color: inherit;
  font-family: inherit; /* Important for vertical align on mobile phones */
  margin: 0; 

Important for vertical align on mobile phones */
}

/* Add a red background color to navbar links on hover */
.navbar a:hover, .dropdown:hover .dropbtn {
  background-color: red;
}

/* Links inside the dropdown */
.dropdown-content a {
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
}
{/* Add a grey background color to dropdown links on hover */}
.dropdown-content a:hover {
  background-color: #ddd;
}
@media screen and (min-width: 600px) {
  .navbar{display:none;}
  ul{display:flex}
}
<div>
    <ul>
      <li><a class="active" href="index.html">Home</a></li>
      <li><a href="html/aboutus.html">About Us</a></li>
      <li><a href="html/menu.html">Menu</a></li>
      <li><a href="html/zoo.html">Zoo</a></li>
      <li><a href="html/parksandwalks.html">Parks and Walks</a></li>
    </ul>
</div>
<div class="navbar">
  <div class="dropdown">
    <button class="dropbtn">Other Pages
      <i class="fa fa-caret-down"></i>
    </button>
    <div class="dropdown-content">
      <a class="active" href="index.html">Home</a>
      <a href="../sunshine/html/aboutus.html">About Us</a>
      <a href="../sunshine/html/menu.html">Menu</a>
      <a href="../sunshine/html/zoo.html">Zoo</a>
      <a href="../sunshine/html/parksandwalks.html">Parks and Walks</a>
    </div>
  </div>
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Ways to implement border spacing using CSS

Here's a snippet of the code I've been working on: HTML: <html> <body> <div id="article"> <h1>TITLE</h1> <p>text</p> </div> </body> </html> CSS: #article { colo ...

Skrollr immediate pop-up notification

Can anyone help me figure out how to make text appear suddenly and then disappear using skrollr? I've been able to get it to fade in and out, but I want it to just show up without any transition. Here's the code I have so far: <div id="style" ...

Display data-content vertically using CSS

Looking for a way to display text vertically one by one with CSS? While the rotation method produces this result: https://i.stack.imgur.com/utAiN.png However, I aim to achieve something more like this: https://i.stack.imgur.com/fuVyb.png If you have an ...

When viewing a webpage on a small browser, the content will automatically expand to fill the

Attempting to utilize responsive CSS media queries to hide the sidebar unless the screen is large or a tablet big enough in landscape mode. It appears to be functioning properly while resizing the browser, but at a certain size, it occupies the entire scre ...

The initial JSON array is displaying correctly, however the subsequent nested arrays are appearing as [Object, object]

I am currently utilizing a wordnik API to gather the word of the day and extract array information. However, I am encountering an issue where the nested arrays are displaying as "object, object" rather than the expected data <script src="https://ajax ...

Adaptable Bootstrap navigation bar

In the process of creating a responsive menu, I have designed a navbar for desktop that includes 3 text links and 3 small pictures that are also links. However, when transitioning to a smaller screen size, my goal is to keep the 3 small pictures as they a ...

Having trouble replacing scss variables in react-h5-audio-player

I recently integrated react-h5-audio-player into my project and followed the instructions on the README page to customize the styles by updating the SCSS variables that control the colors. However, it appears that my custom styles are not being applied. An ...

Is it possible for jQuery UI Dialog to function similar to an iFrame?

Is there a way to set up my dialog box with a form so that when the form is submitted, only the dialog box changes instead of the browser location? ...

Switching the Vue image on Routerlink's isExactActive feature

Is there a way to display different images based on whether a link is active or not? <router-link to="/"> <img src=" :active = isExactActive ? pic_active.png : pic_inactive.png}}" /> //Something along these lines ...

Using the jqueryRotate plugin to rotate an image by 90 degrees

Is there a way to rotate images on a webpage using the JQueryRotate script? I have 10 images that I want to be able to rotate when clicked, but I'm not sure how to implement it. Any assistance would be welcomed. This is the HTML code for the images: ...

Guide on linking an id with a trigger function in HTML and JavaScript

In the snippet below, I aim to create a responsive feature based on user input of 'mute' and 'muteon'. Whenever one of these is entered into the textbox, it will change the color of linked elements with the IDs "text" and "text1" to red ...

What is the process of invoking a Java method through AJAX on a website?

I am trying to figure out how to call the Java method getMessage() from a jar file whenever a button on my webpage is clicked. Can anyone help me achieve this? File name: index.html <!doctype html> <html> <head> <meta charset="utf-8" ...

Modify the color of the text to be white

How can I modify the code below to change the text color to white? The original code is inspired by this question. I am unsure about how the text color was originally set to blue. .footer-background { padding-top: 20px; padding-bottom: 20px; bac ...

Caching HTML5 videos in Google Chrome

I am currently in the process of building a website and have successfully added an HTML5 video. However, I encountered an issue when attempting to change the video file in the background for users to upload a new one. Despite updating the video URL, Chro ...

Having trouble activating my Nav Toggle button on Bootstrap 4

My navbar toggle button isn't working and I'm not sure why. Could it be that I'm missing a class? Any help would be greatly appreciated as I've tried to find a solution on my own without success. Thanks <head> <meta charse ...

Create a screen divided into two separate sections using horizontal split dividers

Trying to figure out how to set a div in HTML and then have a second div take up the remaining space. It seems like it should be simple, but I'm struggling with it. I'd like to have a div with a fixed height and then have another div take up the ...

Preventing scrolling in jQuery UI Draggable when using flexbox

In my project, I am looking to organize a container using jQuery UI draggable/droppable feature. Since the elements in my list are arranged in a straight horizontal line, I have utilized display: flex. This arrangement works well when adding new items to ...

Adjust image size while maintaining aspect ratio

Currently, I am implementing a resize function for an image by using the following code snippet: $('.image_resize').each(function(){ var ww = $(window).width() - 80 - 400; var wh = $(window).height() - 60; var iar = $(this).attr(&apo ...

Setting the height of a div using CSS and navigating between views using Angular UI

Issue One: When moving one square, the border should appear and the menu should cover the entire height. I've already spent 2 hours trying to fix this, but it still doesn't fill the whole height or center vertically. Problem Two: If you make the ...

Looking to subtly transition from the current webpage to the next one with a fading effect?

I'm looking to create a smooth transition between web pages on my site by slowly fading out the current page and fading in the next one when a link is clicked. $(document).ready(function() { $('body').css("display","none"); $(&a ...