Is there a way to make the menu slide up from the bottom button instead of instantly appearing? Looking for solutions in HTML, CSS, and JS

I have attempted numerous methods, but the menu keeps showing up in the same way every time. I've experimented with changing the height from 0 to 20%, width from 0 to 100%, using jQuery, JavaScript, slideUp/Down, hide/Show, adjusting margin-bottom from -50% to 0%, and employing animate, among other things.

$(document).ready(function(){

  $("#settings-menu-btn").click(function(){
    $("#nav").slideDown(500);
  }); 

  //Hiding the menu
  $("#close-menu-btn").click(function(){
      $("#nav").slideUp("slow");
  }); 
});
.nav{
  display: none;
}

.menu {
  padding: 0 10% 10%;
  background-image: linear-gradient(to left, $accent-color, $dark-primary-color);
  background-image: -webkit-linear-gradient(to left, $accent-color, $dark-primary-color);
  border-radius: 5px 5px 0 0;  
  list-style-type: none;
  width: 100%;
  max-width: $max-width-menu;
  max-height: $max-height-menu;
  position: fixed;
  bottom: 0;
  z-index: 10;
  left: 50%;
  transform: translateX(-50%);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="nav" id="nav">
   <ul class="menu" id="menu">
      <li>menu item</li>
   </ul>
</div>

<div class="settings-menu-link">
  <img id="settings-menu-btn" src="settings-icon.png">
</div>

Answer №1

After removing the position and translate styling for the menu, it is now functioning properly.

$(document).ready(function(){

  $("#settings-menu-btn").click(function(){
    $("#nav").slideDown(500);
  }); 

  //Hiding the menu
  $("#close-menu-btn").click(function(){
      $("#nav").slideUp("slow");
  }); 
});
.nav{
  display: none;
}

.menu {
  padding: 0 10% 10%;
  background-image: linear-gradient(to left, $accent-color, $dark-primary-color);
  background-image: -webkit-linear-gradient(to left, $accent-color, $dark-primary-color);
  border-radius: 5px 5px 0 0;  
  list-style-type: none;
  width: 100%;
  max-width: $max-width-menu;
  max-height: $max-height-menu;
 /* position: fixed;*/
  bottom: 0;
  z-index: 10;
  left: 50%;
  background: #ff8a009e;
/*  transform: translateX(-50%);*/
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="settings-menu-link">
  <img id="settings-menu-btn" src="https://img.icons8.com/ios/452/settings.png" style="width:20px;">
</div>

<div class="nav" id="nav">
   <ul class="menu" id="menu">
      <li>menu item</li>
   </ul>
   <button id="close-menu-btn">close</button>
</div>

   

Answer №2

Your problem has been successfully resolved, but let me guide you in this manner first.

Typically, it is not recommended to place your script tag before your HTML code; instead, it should be placed towards the end, just before the closing body tag.

In most cases, loading your script before the page has fully loaded is unnecessary. It is best to avoid doing so.

Furthermore, using the translate property on an element that has a fixed position is unnecessary. You can adjust its position using the top, right, bottom, left properties.

To move your navigation, set a negative value for the top property and create a new class with the top property set to 0.

Then, simply toggle this class on your navigation each time the button is clicked! :)

You can find the solution to your issue here: https://codepen.io/Juka99/pen/WNGjNPG

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

A singular Vuejs Pinia store utilizing namespaced actions

Is it possible to separate pinia actions into two distinct namespaces, allowing access through properties n1 and n2 like this: // current store.n1a('hi') store.n2b() // wanted store.n1.a('hi') store.n2.b() // cumbersome workaround: sto ...

Instructions for receiving user input and displaying it on the screen, as well as allowing others with access to the URL to view the shared input provided by the original user

<h1>Lalan</h1> <input type="text" name="text" id="text" maxlength="12"> <label for="text"> Please enter your name here</label> <br><input type="submit" value ...

Error occurred when sending form data while uploading a file

Upon trying to upload a file using the formData.append(key, value);, an error message is displayed in the value section: The argument of type 'unknown' cannot be assigned to a parameter of type 'string | Blob'. Type '{}' is ...

How to include a Partial View or Child Page into a Master Layout using jQuery/Ajax in ASP.NET MVC

Currently, I am in the process of working on a CRM Admin panel that utilizes a left-hand side panel for navigation to various pages. Within this panel, there are buttons such as Home, About, and Contact. To streamline the layout, I have implemented a mast ...

Learn the steps to flashing images consecutively in sets of four on Android devices

Is it possible to create a blinking effect with up to 4 images appearing back to back? Essentially, I would like one image to be shown and then disappear, followed by the next image appearing in the sequence. This pattern should continue for my specific ...

Learn how to upload an image from Express.js to Google Cloud Storage or Firebase Storage

Currently, I am delving into the world of ExpressJS and attempting to upload an image to Firebase storage using Node. However, I encountered the error message: firebase.storage().ref() is not a function. After researching this issue, I stumbled upon this ...

Every time I attempt to run "npm install" on Visual Studio Code, I encounter an error

Every time I try to run npm install, I encounter this error. My node version is 18.9.1 and I have exhausted all possible solutions. Any help would be greatly appreciated. '''npm ERR! code ENOENT npm ERR! syscall open npm ERR! path C:\Us ...

How can we best understand the concept of custom directives using the link method?

As a beginner in AngularJS, I am looking to implement an autocomplete feature for text input. My JSON data is stored in JavaScript and I need help simplifying the process. Can you provide me with a straightforward solution? The specific requirement is to ...

What are the steps to store and access state variables using session storage in a React application?

I am currently utilizing React version 18.2.0. In my application, I have a component called BodyComponent that stores the data retrieved from an API call in its state as results, along with some filter information in filters. The BodyComponent fetches the ...

AngularJS Filtering - content within html elements

I struggle with filtering and would like to create a personalized filter using the following scenario: When I make a call to a service, I receive a JSON object with HTML that is combined with another string, resulting in messy HTML. My goal is to extract ...

What is causing this JavaScript alert to malfunction?

My current project involves working with ASP.NET and in the view, I have a code snippet that is causing some issues. When I attempt to use Sweet Alert outside of the function, it works perfectly fine. Similarly, if I switch out Sweet Alert for a regular al ...

unique jquery plugin accesses function from external javascript file

As a beginner, I am attempting to create a custom jQuery plugin for which I have a simple HTML form: <form id="registerForm" action = "somepage" method="post" class="mb-sm"> <div class="form-group"> <div class="col-md-12"> ...

Innovative: Enhancing column width dynamically without compromising grid integrity

Currently, I am utilizing Bourbon's Neat library to structure my grid system. Within my code, I have the following setup: section { @include outer-container; aside { @include span-columns(3); } article { @include span-columns(9); } } The chal ...

Allow users to edit the Tinymce text area by simply clicking anywhere within it

On my website, I have implemented a tinymce panel text area. Currently, users can only enter edit mode by clicking on the first line of the tinymce text area. I am looking for a way to allow users to enter edit mode when clicking anywhere inside the tiny ...

Searching for the class _XWk using BeautifulSoup: A beginner's guide

I have discovered a way to locate Google's "quick answer box" by searching for the "_XWk HTML Element using the code below: from bs4 import BeautifulSoup # Beautiful Soup is part of the bs4 package import requests URL = 'https://www.google.com/ ...

What is the best way to use an AngularJs variable as an argument in a jQuery function?

Looking for some help with this jQuery function: function updateProfile(profile, sessionId){ alert(profile,sessionId); } In my HTML code, it's set up like this: <button onclick="updateProfile(profile, {{sessionId}})">Update</button& ...

Enabling CORS Allow-Access-Control-Origin for Chrome on Mobile Devices

I'm encountering a mobile error while testing my new responsive web app on Chrome. I've tried various methods like adding PHP headers and passing headers in AJAX requests. On the desktop, using CORS toggle extension in Chrome helped resolve the i ...

Using Axios to retrieve data from a MySQL database is a common practice in web development. By integrating Vue

I have developed another Vue.js admin page specifically for "writer" where I can display post data fetched from a MySQL database. The admin page called "admin" is functioning properly and responding with all the necessary data. The following code snippet ...

What could be causing my Leaflet popup to suddenly close?

My feature allows users to search for a marker and zoom to its location, triggering the popup to open. Everything is functioning correctly, except that the popup closes after the function executes. I am struggling to pinpoint what is causing the popup to c ...

Unable to invoke server-side function via Ajax

I have implemented 3-tier architecture in my demo application. Currently, I am facing an issue while trying to invoke a method from the business logic layer using Ajax in the presentation layer. It seems like there is an error related to passing the URL. ...