Maintain fixed positioning even when scrolling beyond the boundaries

Currently, I am facing an issue with keeping a div in an absolute position at the bottom right corner. The problem arises when the content overflows and causes the absolute position to move along with the parent instead of staying fixed.

This particular situation is complicated because I am working within the constraints of the Material UI React framework.

The parent element has been styled with a relative position:

const MUIPaper = withStyles({
  root: {
    position: "relative",
    overflow: "auto"
  }
})(Paper);

While the child element uses absolute positioning:

const MUIButton = withStyles(theme => ({
  root: {
    position: "absolute",
    bottom: "1%",
    right: "1%"
  }
}))(Button);

I have come across similar questions from around 2012 stating that it was not possible to resolve this issue. However, I am curious if there have been any updates or workarounds without resorting to using a fixed position?

Answer №1

It appears that the issue stems from your layout design. The behavior you are experiencing with your absolute button is a direct result of this. Consider using a different wrapper where the absolute button is positioned next to the scrolled Paper. Refer to the image below for clarification:

https://i.sstatic.net/fOf4n.png

The red wrapper should have the position: relative property, allowing the button to position itself relative to its parent. This will ensure that the Paper element can function as intended.

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

Encountering a React.js page not found error upon refreshing or when clicking a link directly

I am currently working on a React project hosted at the following link: . When you scroll down, you will come across a section labeled "PRODUCT CATEGORIES". If you click on one of the categories, such as https://i.sstatic.net/QDHh2.png, it should take you ...

Developing a unique dark theme for bootstrap without the need for redundant CSS coding

Currently, I am exploring the most effective way to structure my SCSS dark theme for optimal maintainability. Bootstrap 5 offers the option of setting the data-bs-theme='dark' attribute on the HTML body tag to switch between light and dark themes ...

When attempting to send a fetch request in the most recent rendition of NextJS, it ends up with an error of 'failed fetch'

I am currently working on a nextjs (v.13.4.19) / strapi (v.4.12.5) application and facing issues when trying to make a request to the strapi endpoint using the fetch function. I have attempted several troubleshooting steps such as: changing localhost:1337 ...

"Rotated element in Opera does not maintain event functionality when positioned outside its

Make sure to test this example on Opera (version 12.02) by clicking this link. In Opera, try clicking the red box inside the blue box (event is triggered), then click the red box outside the blue box (event isn't triggered). The container must have p ...

How can I eliminate the error message "WARNING: no homepage content found in homepage.md"?

Starting my journey with KSS utilizing Keith Grant's CSS in Depth as a guide. In section 10.1.4, the author suggests: To begin, create a new markdown file named homepage.md inside the css directory. This file will serve as an introduction to the patt ...

Retrieve the name of the product from the corresponding parent element

My goal is to trigger an alert box with the product name when the "Buy now" button is clicked. I have added the necessary code in jquery to maintain the onclick event of the button. <h2 class="product-name"><a href="product1.php" title="Sample Pr ...

Is there a way to enlarge only the selected card without causing the other cards to enlarge too?

I have a dynamic card in my material ui project. When I click the expand icon for a specific card, it also triggers the expansion of all other cards. How can I ensure that only the clicked card expands without affecting the others? const useStyles = make ...

Interactive horizontal slideshow for hyperlinks - bootstrap framework and model-view-controller architecture

I am currently working on an MVC project that utilizes Bootstrap. My requirement is to have a horizontal menu of links that can slide left and right using arrows (similar to a carousel, but for links instead of images). To be more specific, the menu need ...

Is the Bootstrap carousel floating outside the document's natural order?

As I work on building a landing page for a new startup, I encountered an issue with the layout. I am using a carousel in the "hero section," and everything seemed to be working fine until I attempted to add the next section. To my surprise, the next sectio ...

What is the reason for WordPress theme CSS and JS files loading after the head tag?

I'm experiencing an issue where my Wordpress theme's CSS and JS files are loading after the head tag. Additionally, when I view the source in Firefox, they are showing up in red, indicating incorrect markup. Can anyone help me figure out what&ap ...

Navbar transition issue in Bootstrap

Having trouble with Bootstrap transitions not functioning correctly on my navbar. The issue is when I click the dropdown button in the navbar, the hidden elements appear abruptly without any transition effect. Below is the HTML code being used: <!do ...

Retrieving information from the backend results in an endless cycle, preventing it from loading successfully

My lack of experience with Async functions is evident in the issue I'm facing. The code to fetch templates from a back-end into React keeps repeating without properly setting the state to the data. import React, { useState} from 'react'; imp ...

Ways to populate dynamic choices for multiple Select boxes within an ng-repeat loop

When I click the "Add Row" button on an Html form, dynamic rows are added. Each row contains a 'Country' select and a 'State' select. The issue I am facing is that when I select a country in one row, all other row values change as well. ...

When it comes to using brackets and HTML, I keep receiving an error message indicating that there is no index file

I'm having trouble with this code - it works fine in Code Academy, but I am new to HTML and trying to practice outside of the platform. Every time I try to live preview in Brackets, I get an error message saying "make sure there is an html file or tha ...

Ways to retrieve the baseURL of an axios instance

This question is being posted to provide an easy solution for fellow developers who may be looking for an answer. //Suppose you have an axios instance declared in a module called api.js like this: var axios = require('axios'); var axiosInstance ...

What is the best way to show the current value of a checkbox element in the future?

I want to add multiple checkboxes using this method: $(".btn-sample").on("click", function() { $(".container").append( '<input class="check-sample" type="checkbox" value="'+check_value+'"/>' ); }); The issue I' ...

Large size causing alignment issues with Bootstrap Tooltip位置混乱

I've encountered an issue with the bootstrap tooltip while using fullcalendar.js. The problem isn't with the fullcalendar library itself, as I included it just to provide context. You can view the problem on this JSfiddle link. The tooltip keeps ...

Adjust the z-index of a component within a personalized theme using Material-UI

I need to customize the z-index of components in a Material-UI theme. The z-index used to be set in the base theme, but it has been moved to a separate node module called zIndex.js in version 0.14.2. I want to override the default zIndex values without mod ...

What is the best way to display an AngularJS expression using a ternary operator?

Can AngularJS expressions be shown in a ternary operator? If so, can someone please provide guidance on how to achieve this? Thank you in advance. I have attempted the following, but it is not working as expected: {{ jdFile ? "Job Description File : {{fi ...

Design a dynamic div element for banners that adjusts to different screen

Is there a way to create a responsive div similar to the img-responsive class in Bootstrap, but for a div element that changes its height relative to its width when the window size is adjusted? For example, if you look at the slider on this website "", yo ...