I would like a div element to slide up from the bottom of the page

Could someone please assist me in creating a popup div that appears from bottom to top when a specific button is clicked? I would like the div to be fixed without affecting the overall page content. Any help would be greatly appreciated. Thank you!

$('#sec-menu').click(function() {
  $('.sec-menu-div').toggleClass("active");
});
.sec-menu {
  position: fixed;
  z-index: 777;
  width: auto;
  height: auto;
  bottom: 0;
  background-color: chartreuse;
  left: 50%;
  transform: translateX(-50%);
}

.sec-menu button {
  padding: 5px 50px;
}

.sec-menu-div {
  display: flex;
  justify-content: center;
  position: absolute;
  align-items: center;
  width: 50%;
  height: auto;
  padding: 20px;
  font-size: 20px;
  z-index: 777;
  color: white;
  background-color: darkgoldenrod;
  border-radius: 5px;
  transition: all 0.4s ease;
  transform: translateX(1000%);
}

.sec-menu-div.active {
  bottom: 29px;
  z-index: 777;
  position: fixed;
  width: 100%;
  left: 50%;
  transform: translateX(-50%);
  transition: all 0.4s ease;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="sec-menu">
  <button id="sec-menu">Menu</button>
  <div class="sec-menu-div">
    <p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Sapiente, eligendi.</p>
  </div>
</div>

Answer №1

If you want the element to emerge from the bottom of the page instead of the right side, simply switch translateX to translateY in both classes.

Make sure to adjust the left position and width of the element according to your specific needs - I positioned it in the center for this example.

$('#sec-menu').click(function() {
  $('.sec-menu-div').toggleClass("active");
});
.sec-menu {
  position: fixed;
  z-index: 777;
  width: auto;
  height: auto;
  bottom: 0;
  background-color: chartreuse;
  left: 50%;
  transform: translateX(-50%);
}

.sec-menu button {
  padding: 5px 50px;
}

.sec-menu-div {
  display: flex;
  justify-content: center;
  position: absolute;
  align-items: center;
  height: auto;
  padding: 20px;
  font-size: 20px;
  z-index: 777;
  color: white;
  background-color: darkgoldenrod;
  border-radius: 5px;
  transition: all 0.4s ease;
  transform: translateY(1000%);
}

.sec-menu-div.active {
  bottom: 29px;
  z-index: 777;
  position: fixed;
  transform: translateY(0px);
  transition: all 0.4s ease;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="sec-menu">
  <button id="sec-menu">Menu</button>
  <div class="sec-menu-div">
    <p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Sapiente, eligendi.</p>
  </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

What is the best way to include two class names within a single div using Next.js?

Struggling to include two different CSS classes into a single div element, I encountered some issues. For reference, here is a screenshot: https://i.stack.imgur.com/UuCBV.png https://i.stack.imgur.com/sHNwq.png My code snippet looks like this: blog.js ...

Issue with jQuery's JSON data not being properly transmitted to CodeIgniter (`

Based on my observation, the script provided below seems to be functioning properly: <script type="text/javascript" language="javascript"> $(document).ready(function() { $('#add').bind('keypress', function(e) { if(e.k ...

Click and release file upload

I am working on creating a drag and drop upload feature where the user can drop files onto a div, and then click an upload button to send them to the server. I'm facing an issue with JavaScript not recognizing the variable fd. How can I pass that vari ...

Guide for populating the chosen item in a combobox when the form control option has various parameters

I need help populating the selected saved item into the form control. <select class="form-control"> <option data-parameter-id="685" data-parent-id="1052" data-aggregation-id="null" data-aggregation-parameter="null">ABC</option> & ...

What is the most efficient way to send various props to multiple child components within a React parent component?

Currently, I am working on developing a color palette generator using React. However, I have encountered an issue where all child divs in the color palette receive the same color instead of different colors. Below is the code snippet: class ColorPalet ...

Utilize formData to upload an image to a database with ajax

I'm struggling with the process of uploading an image from an HTML form. The goal is for the form to send the image name along with other data to a PHP page. Instead of using the serialized function, I opted for formData as it has the capability to h ...

Enhance your database interactions with the powerful combination of M

Check out the code snippet below that I'm currently using. AJAX $.ajax({ type: "GET", url: "process.php", dataType: "html", success: function(data){ $(".content").html(data); } }); $("#submit").click(function(){ $.aja ...

The mouseover and mouseleave functions remain active even during window resizing

I wish to create a dynamic menu that appears when hovering over a user, but only if the window size is above 977 pixels. Take a look at my code below: $(document).ready(function() { $(window).on("load resize", function(event){ var windowS ...

Jquery UI slider malfunctioning would require troubleshooting

I am currently working on implementing slider functionality with jQuery. The slider is visible and functioning properly in terms of taking in values, however, the values are not displayed on the screen as expected. I have used console.log to track the ui.v ...

What is the best way to export several 'sub-components' from a single node.js module?

Here's what I mean by exporting 'sub-modules': var fibers = require('fibers'); // this is functional as the 'main' module var future = require('fibers/future'); // also operational as a 'sub' ...

Unable to reset the HTML5 slider successfully

Despite multiple attempts, I have finally reached out for assistance. Here is the code snippet for my slider: <input autocomplete="off" type="range" min="0" max="100" value="50" class="myslider" id="mysliderID-slider" data-fieldid="something"> <i ...

Utilizing Jquery Autocomplete with multiple arrays for data sourcing

I am facing a challenge where I want to display both doctors and their connections in an autocomplete search using jQuery. Although I have successfully displayed the doctors, I'm struggling to categorize and display data from both arrays separately un ...

Adding LocalStorage functionality to buttons in order to switch colors can be done by storing the

I've run into an issue trying to incorporate LocalStorage with the buttons that change colors as themes in JavaScript. I'm new to coding and eager to add this feature to my personal blog. $(document).ready(function () { $(".header--theme-button ...

Sending an HTTP POST request from Angular 4 to Java SpringMVC results in the issue of POST parameters not

Currently, I am developing a REST API using Java Maven Spring Boot and Spring MVC. I have encountered an issue where Angular POST request parameters are not being recognized by SpringMVC's @RequestParam. Below is the Angular code snippet; saveAsSit ...

Ways to align the navigation icon to the left side

I need help positioning my help icon at the bottom of the screen, regardless of the user's monitor size. I've tried using margin and margin-top, but it doesn't adjust properly when changing monitor sizes. Any suggestions or assistance would ...

My custom CSS being overridden by Bootstrap styles

I'm currently working with Twitter Bootstrap's CSS, but it seems to be overriding some of my custom classes. Initially, I placed it before my own CSS in the HTML header (I am using jade and stylus template engines): doctype html html head ...

Include the attribute exclusively for the initial division within a group of corresponding elements

Looking to change the appearance of this HTML code without being able to edit it directly? <form method="POST" id="go123pago"> <div align="center" style="width:220px"> <div style="float:left;padding:10px;width:190px"> ...

The request is being redirected to an invalid destination, resulting in

I am facing an issue with a simple Jquery dialog box on my website. The dialog contains a button that sends the page to the server for processing. However, after some checking, the server redirects the page to another link. The problem arises when I use r ...

navigating up and down html elements using css selectors

Within my code, I have this odd repetitive HTML structure (with no classes) and I'm looking to extract all links along with the accompanying text below each link. While it's simple enough to grab all the links using a basic CSS query selector li ...

Learn how to mock asynchronous calls in JavaScript unit testing using Jest

I recently transitioned from Java to TypeScript and am trying to find the equivalent of java junit(Mockito) in TypeScript. In junit, we can define the behavior of dependencies and return responses based on test case demands. Is there a similar way to do t ...