Issues with transitioning Jquery mobile menu integration from mobile to desktop resolution

Having difficulties incorporating a jquery menu for mobile with the provided code (see below). The issue arises when activating the mobile menu and then resizing the browser window to desktop size, where the menu's class selector has a display:none attribute that I can't seem to remove when the resolution is above 900px.

<div id="header">
        <div class="logoandnav">
            <a id="logo" href="http://localhost/wordpress2"><img src="#></a>
            <ul class="menu">
                <li><a href="http://localhost/wordpress2">Portfolio</a></li>
                <li><a href="http://localhost/wordpress2/?page_id=775">Services</a></li>
                <li><a href="http://localhost/wordpress2/?page_id=736">About</a></li>
                  </ul>
        </div>
    <script type="text/javascript">
    jQuery(document).ready(function($){
    /* prepend menu icon */
    $('#header').prepend('<div id="menu-icon" data-toggle="collapse">Menu</div>');
    /* toggle nav */
    $("#menu-icon").on("click", function(){
        $(".menu").slideToggle();
        $ (this) .toggleClass("active");
         });
          });

        </script>

#header{
background: rgba(255,255,255,0.9);
border-bottom: 1px solid rgba(0,0,0,0.1);
padding: 20px 0 10px 0;
position: fixed;
top: 0;
width: 90%;
z-index: 991;
height:80px;
/*box-shadow:1px 1px 3px rgba(255,255,255,0.5);*/
box-shadow: 0 0 30px rgba(0,0,0,.10);
-webkit-box-shadow: 0 0 30px rgba(0,0,0,.10);
-moz-box-shadow: 0 0 30px rgba(0,0,0,.10);
display:block;
}
#logo{
float:left;
text-align:center;
margin-top:0px !important;
margin-bottom:0px !important;
}
.logoandnav{
max-width:1200px;
margin-left:50px;
margin-top:10px !important;
height:60px;
}
ul li a:hover{border-bottom:3px solid #507abf;color:#507abf;}
.menu{float:right;line-height:50px;}
ul.menu li,.menu{display:inline;}
#menu-icon{display:none;}

ul li{
display:inline;
list-style:none !important;
padding-left:25px !important;
font-family: 'Archivo Narrow', Arial,sans-serif;
font-weight:800;
font-size:22px !important;
}

@media only screen and (max-width: 767px){


ul li{font-size:18px !important;}

#menu-icon{
color:black;
width:42px;
height:30px;
padding:12px 20px 0px 20px;
cursor:pointer;
display:block;
float:right;
margin-top:30px;
font-size:14px;
text-transform:uppercase;
background:url('http://localhost/wordpress2/wp-content/uploads/2013/12/menu_button.png') no-repeat left center;
}

#menu-icon:hover{color:#33B779;}
.menu{display:none;}
.menu{
clear:both;
position:absolute;
top:70px;
right:0px;
width:140px;
z-index:1000;
padding:5px;
background-color:white;
border:1px solid grey;
line-height:30px;
}

Answer №1

Update the code from

@media only screen and (max-width: 767px)
to
@media screen and (max-width: 767px)

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

The element's height appears to be fluctuating unexpectedly when I attempt to adjust it using percentage values within a narrow range

I'm utilizing React and Bootstrap in this project. Here's an overview of my code: I have an element with height set to 0, in rem. My goal is to make the height of this element increase as I scroll down the page, creating the illusion that it is ...

MVC4: Exploring the Strategy for Handling Nested Ajax Requests

Creating a form in a web application, I implemented filtering data based on user selection using AJAX to retrieve JSON nested data from BankPlans table. However, I encountered an issue when attempting to fetch all required documents for each bankID from an ...

Difficulty with CSS selector in highlighting checkboxes

After moving the label after the checkbox, this CSS selector is now working. input[type=checkbox]:checked + label { color: red; } <input type="checkbox"><label>Checkbox1</label> However, I want the checkbox to also ...

The hover effect and image opacity adjustment seem to be malfunctioning in my HTML/CSS code

Currently, I am in the midst of a web project and my goal is to implement a hover effect on the first card containing an image. The desired outcome is for the card to move upwards upon hovering, allowing the image to become fully visible with an opacity se ...

Close FaceBox programmatically

Struggling to figure out how to close jQuery Facebox from the code behind. When inserting a new record through FaceBox, I need it to automatically close upon successful insertion. Anyone know how to accomplish this task? ...

Guide to implementing Callback functions in Class using JavaScript/jQuery

I have a unique class that I've developed to handle CRUD operations for my website. This class helps in managing form paths and table paths for adding, listing, editing, and deleting data. It also includes a feature to reload the view using ajax after ...

Creating a bootstrap carousel configuration

I recently encountered a problem while using a single bootstrap carousel. The carousel contains multiple items/images to display, with one of them needing to be active initially. Below is the code snippet: <div id="myCarousel" class="caro ...

What is the best way to manage the alignment of elements within their parent containers in my situation?

Attempting to replicate the design of a website by starting with the navigation bar. <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>test</title> <link rel="stylesheet" href="https: ...

Tips for maintaining the aspect ratio of an image while ensuring it always occupies 100% width and automatically adjusts its height

I've searched everywhere but can't seem to find the right CSS solution for my problem. How can I ensure that an image always fills 100% of the height and width of the screen while maintaining its aspect ratio? .myimage { object-fit: cover; widt ...

The rotation transformation on the Z-axis occurs once the animation has finished

Currently, the rotation on the Z-axis is occurring after the animation, even though I am still in the early stages of creating an animated hand opening. The intention is for the fingers to only rotate on the X-axis to simulate a realistic hand opening moti ...

Trouble with the functionality of the Bootstrap collapse button

I am facing an issue where clicking on the collapse button does not trigger any action. I have tested it on both of my laptops, ruling out any problems with the web browser. <!DOCTYPE html> <html> <head> <meta charset="utf-8"> ...

Performing two consecutive nested AJAX requests in jQuery using JavaScript

I am facing an issue with my code. My goal is to create a cryptocurrency ranking feature on my website. I have integrated an API that provides logos, symbols, indices, prices, etc. of cryptocurrencies. However, I encountered a problem as this API doesn&apo ...

What is the best way to create a sleek typewriter effect transition by hovering between tabs?

When hovering over a tab, the content in the main content area's child div should be displayed from a sibling div that holds the content. Initially, the details div style is set to hide the contents but upon hover, it is displayed. The described func ...

Performing an AJAX post request in PHP is resulting in an unexpected HTML comment being returned, which ultimately

I am encountering an issue with my index.html file that is making an AJAX request to a PHP page for JSON data. The code seems to be functioning properly, but occasionally the PHP file returns '' before the actual JSON text. The problematic retur ...

When the overflow is set to visible, the background color vanishes

Here is the CSS code I have written; #container { width: 1300px; background-color:green; margin:0 auto; overflow:hidden; } #menu { float:left; width:20%; background-color: yellow; } Even after extensive searching on Google, I ...

Columns of varying widths, with a solid border separating each one

I am working on a layout with a fluid width left column and a fixed width right column. My challenge is to add a border that spans the entire height of the tallest column. Below is a simplified version of my current setup: .left { width: 100%; fl ...

The CSS attribute for setting the background color of Shell in css/default.css does not produce any visible

Currently working my way through the book "Eclipse 4 Plug-in Development by Example Beginner's Guide", specifically on the section titled "Time for action – styling the UI with CSS". The guide instructs to edit the "css/default.css" file and add th ...

Having trouble implementing the jQuery UI layout plugin in my Angular.js app with routing, specifically on the second view

Currently, I am developing a simple angular.js application that involves two views: a HOME view and an ALT view. My goal is to incorporate a jQuery UI Layout plug-in on the ALT view in order to create a layout with North, South, East, and West regions. Ho ...

Is it possible to display a "click" message when a button is hovered over using CSS?

Whenever I hover over a button, I struggle to receive the appropriate message like "click" or "enter" before actually clicking it. How can I use CSS to style my buttons in a way that allows for this pre-click messaging? I have tried approaches such as .bu ...

Tips for aligning two columns of listed items vertically with Bootstrap 5 or CSS

Having difficulty aligning two columns containing text - specifically, two lists. The goal is to have both columns on the same row with centered lists and their respective items aligned as normal bullet points. Any advice would be greatly appreciated. C ...