Show a concealed vertical menu on mobile using CSS

I successfully implemented a drop-up footer on my website:

$('#drop-up-open').click(function() {
  $('#drop-up #drop-upDashboard').slideToggle({
    direction: "up"
  }, 300);
  $(this).toggleClass('drop-upClose');
}); // end click
#drop-up {
  position: absolute;
  bottom: 0;
  width: 100%;
  padding-bottom: 4%;
  z-index: 100;
  margin-left: auto;
  margin-right: auto;
  left: 0;
  right: 0;
}

#drop-up-open {
  cursor: pointer;
  text-decoration: none;
}

#drop-up .drop-upClose {}

#drop-up #drop-upDashboard {
  display: none;
}

@media screen and (max-width: 1000px) {
#drop-up #drop-upDashboard{ 
display:block; }
}
<div class="container">

    <!-- Jumbotron Header -->
    <header class="jumbotron panel-heading">

    <p class="text-center">
    
                Text getting covered by drop-up menu on mobile

    </p>

    <section>
                <a href="#"><button> Main button </button></a>
    </section>
    
    </header>

<div id="drop-up">
  <a href="#" id="drop-up-open">Open</a>

  <div id="drop-upDashboard">
    <p>It's now open!</p>

    <div class="row">

      <div class="col-md-3 col-xs-12">
        <section> <a href="#"><button>
                              
                            <p>Button 1</p>

                        </button></a> </section>
      </div>

      <div class="col-md-3 col-xs-12">
        <section> <a href="#"><button>
                            
                            <p>Button 2</p>

                        </button></a> </section>
      </div>

      <div class="col-md-3 col-xs-12">
        <section> <a href="#"><button>
                            
                            <p>Button 3</p>

                        </button></a> </section>
      </div>

      <div class="col-md-3 col-xs-12">
        <section> <a href="#"><button>
                            
                            <p>Button 4</p>

                        </button></a> </section>
      </div>

    </div>
    <!-- row -->
  </div>
  <!-- dashboard -->
</div>
<!-- drop-up -->
</div>
<!-- container -->

Upon clicking the div with id="drop-up", the menu opens from bottom to top on desktop view. Now, I want this menu to be automatically displayed on smaller devices without needing a click.

The goal is for the drop-up menu to occupy the same portion at the bottom of the page on mobile and tablet views, requiring users to scroll down to see it, unlike on desktop view. Any advice on achieving this?

Answer №1

You have the option to enclose everything in a flex box and let the body flex to occupy the remaining space, which will position your footer at the bottom level. This method also seems to respond well when you switch to responsive design.

However, this approach currently seems somewhat makeshift, as if you place a border around the flex box container, it will only conform to its original 100% size.

$('#drop-up-open').click(function() {
  $('#drop-up #drop-upDashboard').slideToggle({
    direction: "up"
  }, 300);
  $(this).toggleClass('drop-upClose');
}); // end click
html, body {
  height: 100%;
}
#drop-up-open {
  cursor: pointer;
  text-decoration: none;
}

#drop-up .drop-upClose {}

#drop-up #drop-upDashboard {
  display: none;
}

@media screen and (max-width: 200px) {
  #drop-up #drop-upDashboard{ 
  display:block; }

  html, body {
    height: auto !important;
  }

}


.container {
  display: flex;
  flex-direction: column;
  border: 1px solid black;
  min-height: 100%;
}

.body {
  flex: 1;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">

    <!-- Jumbotron Header -->
    <header class="jumbotron panel-heading" style="background-color: yellow; opacity: 0.7">

      <p class="text-center">

                  Text getting covered by drop-up menu on mobile

      </p>

      <section>
                  <a href="#"><button> Main button </button></a>
      </section>

    </header>
    
    <div class="body" style="background-color: orange; opacity: 0.3">
      a body
    </div>

  <div id="drop-up" style="background-color: lightblue; opacity: 0.7">
    <a href="#" id="drop-up-open">Open</a>

    <div id="drop-upDashboard">
      <p>It's now open!</p>

      <div class="row">

        <div class="col-md-3 col-xs-12">
          <section> <a href="#"><button>

                              <p>Button 1</p>

                          </button></a> </section>
        </div>

        <div class="col-md-3 col-xs-12">
          <section> <a href="#"><button>

                              <p>Button 2</p>

                          </button></a> </section>
        </div>

        <div class="col-md-3 col-xs-12">
          <section> <a href="#"><button>

                              <p>Button 3</p>

                          </button></a> </section>
        </div>

        <div class="col-md-3 col-xs-12">
          <section> <a href="#"><button>

                              <p>Button 4</p>

                          </button></a> </section>
        </div>

      </div>
      <!-- row -->
    </div>
    <!-- dashboard -->
  </div>
  <!-- drop-up -->
</div>
<!-- container -->

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

Utilizing jQuery AJAX to enable a functional back button feature upon modifying HTML

While there are numerous inquiries regarding jQuery and Back button issues, the focal point is typically on maintaining history features when using the browser back/forward buttons. One specific query I have is how to load an AJAX-affected HTML page when ...

Easiest homemade variations and pairings

Imagine having a basic array like ["apple", "banana", "lemon", "mango"];. For example, if we were to find the straightforward hand-rolled combinations of this array, selecting 3 items, but allowing for repetition: let array = ["apple", "banana", "lemon", ...

w3schools example showcasing the power of AJAX

How can I run this example on my local machine? http://www.w3schools.com/ajax/tryit.asp?filename=tryajax_httprequest_js (page no longer available) I want to access the XML file hosted on w3schools without moving it to my machine. Can I run the HTML and J ...

Using jQuery and AJAX to dynamically add data to POST parameters

Hello, I have a question that may sound like one from a newbie. I am trying to figure out how to insert a variable into a parameter for a POST request instead of simply writing the number in directly: var x = 3; id=(the var x needs to be here)&appid=4 ...

I am transmitting a function from an object to an array. However, when I attempt to calculate the sum of the array, the

Below is the provided code snippet: var myObject = { x: 5, h: function(){ varOne = 2*2; varTwo = 3*2; varThree = varOne*varTwo; }, d: 4 }; var g = myObject.h(); var xyz = g; var abc = 2; var efg = 3; var somearray = [xyz,abc,efg ...

Running cy.task after all test suites can be done by adding the task in a

I need some guidance on running cy.task after executing all test suites. I have a file generated at the start of the tests that I would like to remove once they are completed. Regardless of whether any tests passed or failed, I want to trigger cy.task im ...

What is the best way to ensure that my dynamically generated div shows up within the container div?

Web Development <div id="container"> <div id="wrapper"> </div> <span id = "waveNum">Current Wave: 0</span> <input type = "button" value = "Start Game" onclick = "startGame()"></input> </div> ...

Pictures not sizing properly within the grid layout

When attempting to create a simple grid with square images, I encountered an issue where the images were overlapping each other and appearing too large when directly placed inside the grid. In order to resolve this problem, I explored using CSS to adjust t ...

When using Jinja2 and Flask, the Bootstrap Tabs only show the content for the first tab and not for the others

Utilizing Jinja2 and Python for HTML generation, along with Bootstrap for CSS and JS, I am attempting to create Bootstrap pill tabs using Jinja2 loops and additional logic. The following code represents my approach: When invoking the render_template funct ...

Learn how to calculate and showcase time discrepancies in minutes using Angular2

I am currently working on an Angular app that displays orders using the *ngFor directive. Each order has a datetime field indicating the date it was created. My goal is to implement a timer that shows how long a customer has been waiting for their order ...

Elevate column to top position in mobile display with Bootstrap

I am currently working with Bootstrap column classes and have set up four columns as follows: <div class="col-md-3"> @include('schedulizer.classes-panel') @include('schedulizer.time-span-options-panel') @include(&apos ...

Axios.post makes the request twice

Can anyone help me with an issue regarding axios.post where it sends the same request twice with identical data? I have searched online for a solution but haven't found anything. Any ideas on how to resolve this problem? https://i.sstatic.net/lXTss.p ...

What method can I use to modify an existing decorator directive in AngularJS to automatically select all checkboxes?

After implementing a decorator directive to create a checkbox list following the solution provided in a previous answer on Stack Overflow, where can I find further guidance on adding a main checkbox that toggles the selection of all checkboxes? Is it poss ...

Generating Placeholder Variables Within a v-for Iteration

Encountering a problem with Vue-JS involving v-for loops and v-model properties. I have an array of items: <input v-for="i in list" v-model="i.model" ... (other tags that use i) > </input> Accompanied by some JavaScr ...

The 'v-model' directive necessitates a valid attribute value for the left-hand side (LHS)

I am facing an issue with my Vue application. I have a table where each row has its own unique id. I need to show or hide certain elements based on a condition in the v-model directive which compares the row id with a value in the model. The current code s ...

The jQuery UI dialog stubbornly refuses to close when tapped, yet opens without hesitation

I'm struggling to understand why my dialog boxes are not closing when I tap outside of them. I've tried using different selectors such as document, window, .ikon_picmap, but nothing seems to be working. What am I missing here? Check out the code ...

Avoiding Memory Leaks and Managing JS Heap Size While Polling Large Amounts of Data Every 5 Seconds with Vuex

I'm currently working on a Vue application that utilizes Vuex for state management. Within this application, I have several store modules set up at the root level. Periodically, every 5 seconds, I retrieve a large amount of data and update the store s ...

Challenges with bcryptjs and MySQL

I am facing an issue while trying to save a user in the database and create a hash of their password to save instead of the actual password. However, every attempt I make results in a RangeError: Maximum call stack size exceeded. Below is the User code sn ...

Find the sum of every combination of numbers in the array

I've reviewed my code countless times and I'm stumped by the issue. My code is designed to calculate all possible sums of numbers within an array. It works perfectly when there are only 3 numbers in the array, but once I add a fourth number, it i ...

Access to JSON.stringify is prohibited

I have an array containing objects in JavaScript that I need to save as a .json file. Prior to saving the objects, I displayed them using console.log. // Client Object {id: "1", color: "#00FF00"} Object {id: "2", color: "#FF7645"} Object {id: "3", color: ...