The webpage fails to automatically scroll to the bottom

I'm having an issue with a div element that I need to make scrollable.

The menu is contained within this div (covering the full screen) you can see it here. When hovering over an element with children, the menu expands and extends beyond the screen. This is why I added scrolling, but it doesn't scroll all the way to the bottom (hiding the last menu item).

Here is my CSS and HTML:

.tablet-menu {
  display: none;
  background: #000;
  position: fixed;
  height: 100%;
  width: 100%;
  opacity: 0.7;
  z-index: 1001;
  -webkit-transition: all 0.8s ease-in-out;
  -moz-transition: all 0.8s ease-in-out;
  transition: all 0.8s ease-in-out;
  -webkit-transition-delay: 0.2s;
  -moz-transition-delay: 0.2s;
  transition-delay: 0.2s;
}
.tablet-menu.show {
  display: block;
}
.tablet-menu-scroll {
  overflow: scroll;
  height: 100%;
  width: 100%;
}
.tablet-menu ul {
  top: 0;
  bottom: 0;
  position: relative;
  text-align: center;
  padding: 0;
  margin: 0;
}
.tablet-menu li {
  color: #FFF;
  background: #000;
}
.tablet-menu li a {
  text-transform: uppercase;
  font-family: "Roboto Slab", Times, Georgia, serif;
  font-weight: bold;
  border-radius: 2px;
  border-bottom: 1px solid white;
  position: relative;
  display: block;
  padding-top: 4%;
  padding-bottom: 4%;
}
<div class="tablet-menu">
  <ul class="tablet-menu-scroll">
    <?php wp_nav_menu(array ( 'theme_location'=>'new-menu', 'container' => '', 'items_wrap' => '%3$s' )); ?>
  </ul>
</div>

Apologies for the PHP code, as I am working on WordPress. I included a modified version of my menu without revealing the real page names.

You can view it here: click

I'm unsure where the problem lies exactly.

Answer №1

If you want to adjust the padding on your tablet menu, you can try decreasing either the padding-top, padding-bottom, or both, like so:

.tablet-menu li a {
padding-top: 3%;
padding-bottom: 3%;
}

Answer №2

To organize as desired below:

$(function(){
  $('#show').on('click', function(){
      $('.tablet-menu').addClass('show');
  });
});
.tablet-menu{
display:none;
overflow:scroll;
background:#000;
height:100px;
width:300px;
opacity:0.7;
z-index:1001;
  -webkit-transition: all 0.8s ease-in-out;
  -moz-transition: all 0.8s ease-in-out;
  transition: all 0.8s ease-in-out;
  -webkit-transition-delay: 0.2s;
  -moz-transition-delay: 0.2s;
  transition-delay: 0.2s;
}
.tablet-menu.show{
display:block;
}
.tablet-menu-scroll{
height:100%;
width:100%;
}
.tablet-menu ul{
top:0;
bottom:0;
position:relative;
text-align:center;
padding:0;
margin:0;
}
.tablet-menu li{
color:#FFF;
background:#000;
}
.tablet-menu li a{
text-transform: uppercase;
font-family: "Roboto Slab", Times, Georgia, serif;
font-weight:bold;
border-radius:2px;
border-bottom:1px solid white;
position:relative;
display:block;
padding-top:4%;
padding-bottom:4%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<div class="tablet-menu">
          <ul class="tablet-menu-scroll">
                <li>product</li>
                <li>product</li>
                <li>product</li>
                <li>product</li>
                <li>product</li>
                <li>product</li>
                <li>product</li>
                <li>product</li>
            </ul>
      </div>

<button id="show">Reveal</button>

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

Drop down menus fail to appear after the screen has been resized

Creating responsive menus involves using ordered and unordered lists, along with CSS for styling. I have added a script to dynamically generate dropdown menus, but encountered an issue where nothing appears on the screen upon resizing - only the backgrou ...

What is the best way to eliminate a CSS style from a div?

I have implemented jQuery Autosize to automatically adjust the height of textarea elements. It works perfectly when I focus on the textarea element. However, when I blur out of the textarea, I want to reset the height to its default value. I am unsure of ...

How to dynamically change the title of a group box in Angular 8 using TypeScript

I am working with a component that includes a groupbox: <fieldset> <legend>Title</legend> </fieldset> Could I change the title of the groupbox using TypeScript code? ...

The PHP email that was sent contains two empty fields

Looking for assistance with an issue in my PHP contact form. I found the code online and made some modifications, but I'm encountering a problem where two of the fields (email and state) are coming through as blank in the email, even though all other ...

Identify support for the :first-child pseudo-class

Is there a way to determine with JavaScript whether the browser is compatible with the CSS :first-child selector? ...

The parent of these inline-blocks does not adjust its width to match its children, even when the parent has overflow-hidden applied

This is the code snippet I have been working with: <!DOCTYPE html> <html> <head> <style> div.ex2 { background-color: lightblue; width: 110px; height: 110px; overflow: ...

Is it possible to determine the height of a div that has been assigned `overflow-y: auto`?

Is it possible to determine the height of a div element with its content without using overflow-y: auto? I would like to keep overflow-y: auto applied but still be able to calculate the height of the div as if the overflow property was not there. Specifi ...

Enhanced Slider Display featuring Multiple Posts for Improved Performance

My Sample Page features a slider that displays over 200 posts, each containing 5 images. However, the slider loads all the images at once, causing my page speed to be very slow. I am looking for an optimized way to display the slider without compromising l ...

Incorporate classes into multiple titles by utilizing the text within the title

Here is some HTML code: <tr class="more-options"> <td width="190px" valign="top" class="ms-formlabel"> <H3 class="ms-standardheader"> <nobr>Required Hidden 1&l ...

Break up a list into separate paragraphs and style each word using individual CSS

I have a user-generated paragraph that consists of a list of words separated by commas, such as "dog, cat, hamster, turtle." I want to be able to individually assign attributes to each word in the list. Check out this image for reference In the example i ...

There is no automatic margin calculation for the input element, however, the margin can still be adjusted using metrics and

I'm encountering an issue with the width of an input element within a table cell. The input element is defined in the following way: <td><input class="form-control input-small my-input-narrow" type="number"></td> Unfortunately, the ...

The z-index remains in limbo until the transition is complete

Exploring the concept of "folding" elements through the use of rotate3d(), I encountered an issue with only one side of my fold. During the animation, the z-index seems to be ignored, but suddenly jumps to the top at the end. My suspicion lies in the z-axi ...

What is the best way to configure FormIt with ModX Revolution to automatically redirect to a specific web page ID, such as www.myurl.com/index.php#contact?

A concern I have is regarding a one-page HTML website I created with multiple sections representing different pages. The issue I'm encountering is related to the FormIt contact form, which is functioning properly but not redirecting to the correct ID ...

To add a code snippet to the right side of a paragraph using CSS, place it at the end of the

Is there a way to insert code at the end of each paragraph and have it aligned to the right on the same line as the last sentence? Update: I initially tried using float:right, but encountered an issue with vertically aligning the code with the last line ...

Ways to create a div that automatically increases in height to fit its text when the browser size decreases

In the following code snippet, there is a top bar with a lengthy text: <div class="topbar"> <div style="float:left;height:36px;line-height:36px;text-transform: none;"> long text.... </div> </div> Within the topbar ...

Tips for expanding an md-nav-item in Angular Material

Need help on stretching the md-nav-item element illustration 1 ------------------------------------------------ | ITEM1 | ITEM 2 | ------------------------------------------------ illustration 2 ------------------------------------------------ | ...

Facing difficulties in retrieving my static files with Express and Node.js

I'm puzzled as to why express isn't able to access my static file to display my CSS. Here is the code snippet from express.js: app.use(express.static(__dirname + '/public')); Contents of style.css: <style type="text/css"> bod ...

Alignment in HTML / CSS / ReactJS: Leveraging the Text-align attribute

My attempt to align the text to the right within my div element has been unsuccessful. Despite using text-align: right and width: 100%, the issue persists. It seems that the problem lies within the left-side and right-side attributes, but I am unable to pi ...

Struggling to make addClass and removeClass function correctly for the development of the unique "15 puzzle" game

I am currently in the process of creating a version of "the 15 game" using jQuery in HTML. You can find more information about the game on this page. The objective of the game is to rearrange a table of "boxes" in ascending order from 1 to 15. Below is th ...

Identifying between a webview and browser on an Android device

I need to differentiate between a webview and a browser in Android to display a banner only for users accessing the app via a browser, not through a webview. I've tried using PHP code but it doesn't work as expected. Is there another method to a ...