Tips for enabling scrolling on the correct floating menu when there is overflow

I have been attempting to make the right floating menu scroll when overflowing, but so far, I have been unsuccessful. Here is the link to the JSFiddle demonstrating the issue: https://jsfiddle.net/xuwtqmj3/.

.menu {
  position: fixed;
  float: right;
  right: 0;
  top: 0;
  background-color: #f0f0f0;
  overflow: auto;
}

.menu-left {
  float: left;
  overflow: auto;
}
<html>

<head>
  <title>test</title>
</head>

<body>
  <div class='menu'>
    <span>Menu</span>
    <div class="menu-left">
      <span>111</span>
      <ul>
        <li>test</li>
        <li>tttttt</li>
      </ul>

      ...... more

      <span>66</span>
      <ul>
        <li>test</li>
        <li>tttttt</li>
      </ul>
    </div>
  </div>
  <div>
    <pre>
    asdfasdf
    asdf

    ...... more

    sfd
    </pre>
  </div>
</body>

</html>

I have attempted to solve this issue by adding display: inline-block, but this did not work. I also tried wrapping the ul inside a span, but that did not work either.

Answer №1

To modify the size of the menu, simply add the height property to the .menu class. For example, you can set height:100vh;

.menu {
    position: fixed;
    float: right;
    right: 0;
    height:100vh;
    top: 0;
    background-color: #f0f0f0;
    overflow: auto;
}
.menu-left {
  float: left;
  overflow: auto;
}
<html>
<head>
<title>test</title>
</head>
<body>
<div class='menu'>
<span>Menu</span>
<div class="menu-left">
<span>111</span>
<ul>
<li>test</li>
<li>tttttt</li>
</ul>

<span>22</span>
<ul>
<li>test</li>
<li>tttttt</li>
</ul>

<span>33</span>
<ul>
<li>test</li>
<li>tttttt</li>
</ul>
<span>44</span>
<ul>
<li>test</li>
<li>tttttt</li>
</ul>
<span>55</span>
<ul>
<li>test</li>
<li>tttttt</li>
</ul>
<span>66</span>
<ul>
<li>test</li>
<li>tttttt</li>
</ul>
</div>
</div>
<div>
<pre>
asdfasdf
asdf
asdf
asfd
a



sdfsdf
sd
fs
dfsd
fsfd
sdf



sdfsdfs
sdf
sfd
</pre>
</div>
</body>
</html>

Answer №2

One issue lies in the fact that the right sidebar is set to position fixed, causing it to maintain its original height. By setting the height to 100vh or 100%, the right sidebar will adjust to the height of the viewport or browser screen, leading to the appearance of a scroll bar.

Consider this information for any similar situations you encounter in the future.

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

Creating a character jump animation on an HTML5 canvas

While following a tutorial on creating character animations, I encountered an issue. The tutorial, located at , made it easy to make the character move left (the right movement was already implemented). However, I am struggling with how to animate the char ...

What is the best way to convert every database field into a public variable in PHP?

After running the query below, I have retrieved all database fields: "SHOW COLUMNS FROM admin" Now I am curious about how to convert each field into a public variable within a class structure since I am working with object-oriented PHP. My first step i ...

Update a script that handles input float labels to support textarea elements as well

I am looking to modify a float label script that currently works for input boxes in order to make it work for textareas. I attempted to add $fields.on("textarea", floatLabel) to the script but it did not produce the desired result. Any suggestions or assis ...

What is the best way to ensure that an image perfectly fits within a div container?

My goal is to make my image occupy half of the div's width and 100% of the height. However, I am facing an issue with a lingering white bar at the bottom. Can you offer some guidance on how to resolve this? Take a look at the site preview .contain ...

Tips for designing an Ionic app with a Pinterest-inspired layout

Recently stepping into the world of Ionic development, I find myself facing a challenge in creating a Pinterest-inspired layout using Ionic. Specifically, I am struggling to achieve a two-wide list of items with varying heights. Can anyone offer guidance ...

How can I make an inline h1 with a span that is aligned to the end?

I am attempting to create the most basic react app possible and I want to design a header using Bootstrap 4. The header will have two parts: the first part on the left side and the second part on the right side. Currently, my code looks like this: <di ...

Tips for choosing a specific set of list items using HTML

In my application, I have a list that is divided into sections like "currently viewing as," "recently viewed," and "staff." All elements in the list share the same classes, making it difficult to identify a specific list element in a particular section, su ...

I am looking to apply the Normal texture to the Fbx model, but I am encountering issues with the normal not functioning

This is an example. I am in need of a model with both a color map and a normal map. Just like the one seen in Microsoft 3D Viewer. https://i.sstatic.net/DU2vo.png Furthermore, I already have a model with a normal map. My approach involves using the re ...

Utilize HTML5 localStorage functionality

I have a good understanding of utilizing HTML5 localStorage with methods like localStorage.getItem/setItem. However, I am currently trying to figure out the implementation for a dynamic page. Let me explain the scenario: On my dynamic page (myPage.jsp), ...

Moves are chosen to move downward when positioned next to an inline-block level element

Check out this jsfiddle example How can I prevent selects from moving down when there is an inline-block level element next to it? <select> <option value="" >Day</option> </select><select> <option value="" >Mon ...

Modifying CSS stylesheet does not alter the background color

body { background-color: bisque; } <!DOCTYPE html> <html> <head> <title>Reading</title> </head> <body> <h1> <button><a href="index.html">Home</a></button> & ...

What is the best way to resize a Bootstrap 4 form to perfectly fit the screen width in mobile view?

I need help with a Bootstrap 4 form that I want to adjust to fit the viewport of mobile users. Currently, mobile users see this: https://i.sstatic.net/JjRa8.png The form inputs do not fill the width of the screen, and I want them to take up the full wid ...

What are some methods for embedding HTML content onto a specific section of a webpage in a Node.js + Express application, without displaying it as the

Objective My goal is to insert a portion of HTML into a web page. Issue The page is not displaying properly with the desired styling and layout. I have a specific page that must be written in plain HTML rather than Jade, although I will still be usin ...

The HTML element failed to be inserted

Currently, I am involved in a project based on .NET Core for my organization. This project entails loading work orders from our SQL database using Entity Framework and then filtering them to display as markers on a map via the Google Maps API for our insta ...

Tips for defining conditions within the style attribute in JSP

Below is the code that I attempted: <div style="width:85%;"> <input class="formbutt" value="AddNew" title="AddNew" type="button" style="{(${projectEnvironmentBean.divStyle}=='dipslay:none') ? 'display:block' :'display: ...

Tips for creating a responsive background image without excessive scaling:

I'm currently working on a website with a focus on responsibility, and I've incorporated 'waves' SVG images as a background-image. The issue arises when viewing the site on smaller screens, such as mobile devices, where the background a ...

Craft an engaging and dynamic Image map with SVG technology to elevate responsiveness and interactivity

I'm currently working on a website and I need to create two clickable sections on the home page. Each section will lead to a different specialization of the company. To achieve this, I decided to use a square image split into two right-angled triangle ...

Exclusive Pages in NextJS for Development Purposes

I want to set up a /storybook page specifically for development purposes. However, I do not want this page to be accessible in production mode. How can we make that happen? ...

Tips for transferring the input text box value to angularjs when clicking on the text box

Here is the HTML code snippet: <tr ng-repeat="c in client"> <td><input type="text" id="id" value="{{c.id}}" onclick="display();"></input></td> <td><input type="text" value="{{c.fname}}"></td> </ ...

I am interested in creating a header that remains static

Currently, I am attempting to create a header that has a freezing effect. My goal is to have a banner at the top with a navigation menu underneath it. When scrolling down, I want the banner to disappear but have the navigation menu remain frozen at the top ...