TailwindCSS: Footer component overlaps central panel when scrolling on mobile devices

https://play.tailwindcss.com/notWWuhDpr?size=546x752

My project consists of three key components:

  1. The header
  2. A scrollable main panel
  3. The footer

While it was relatively easy to implement this layout on the web using the code provided in the link above, I encountered some issues with the behavior of the main panel on mobile devices. In this video, you can see that the bottom portion of the panel is obstructed by the bottom navbar and exhibits an unusual scrolling behavior. The initial scroll behaves as intended, allowing overflowed content to be scrolled through. However, when attempting to scroll on the side edge, the entire panel component moves erratically up and down.

Answer №1

I am unsure of what you mean by "acts weirdly". However, I believe it is more beneficial to design your layout so that the entire screen adapts to accommodate your elements, rather than using fixed variables for the footer as demonstrated in this Tailwind preview:

<div class="flex h-screen flex-col">
  <div class="flex-none">
    <div class="m-4 flex w-[calc(100vw-2rem)] space-x-2 rounded-lg bg-gray-300 p-4 shadow-md">Header</div>
  </div>
  <div class="flex-grow overflow-hidden">
    <div class="m-4 rounded-t-lg bg-white shadow-lg">
      <div class="mx-auto max-w-2xl p-6">
        <!-- mainpanel -->
        <div class="h-[calc(100vh-15rem)] overflow-y-scroll">
          <text class="text-5xl"> Lorem ipsum orem ipsumorem ipsumorem ips... </text>
          <textarea>asdf</textarea>
        </div>
      </div>
    </div>
  </div>
  <footer class="m-4 mt-0 w-[calc(100vw-2rem)] rounded-b-lg border-t-2 border-gray-200 bg-gray-300 shadow-lg">
      <div class="flex items-center justify-center space-x-4 p-4">
        <button class="btn-solid h-10 w-32 disabled:cursor-not-allowed disabled:bg-gray-100">hello</button>
    </div>
  </footer>
</div>

As for the scrolling issue, I noticed the font size is too large on mobile screens, causing content to extend beyond the viewport and create an unwanted horizontal scroll. This can be resolved by adjusting the font size from text-5xl to maybe text-3xl md:text-5xl, ensuring the larger font size is only applied when there is sufficient space.

I hope this guidance sets you in the right direction. Have a wonderful day!

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

CrossBrowser - Obtain CSS color information

I'm attempting to retrieve the background color of an element: var bgcolor = $('.myclass').first().css('background-color') and then convert it to hex function rgbhex(color) { return "#" + $.map(color.match(/\b(\d+ ...

Utilizing the '::marker' pseudo-element for generating Markdown-inspired headers

This code snippet is functioning correctly, however, I have a suggestion to make it more appropriate. Instead of using '::before', why not try using '::marker'? I attempted this adjustment but encountered an issue. Can anyone explain wh ...

Effortlessly navigate between Formik Fields with automated tabbing

I have a component that validates a 4 digit phone code. It functions well and has a good appearance. However, I am struggling with the inability to autotab between numbers. Currently, I have to manually navigate to each input field and enter the number. Is ...

Vertical Image Alignment in Bootstrap 3

Looking for some help with a basic HTML structure here. I have a single row divided into two columns, each containing an image of the same size. What I need is to center one image both horizontally and vertically in each column. <div class="containe ...

Harnessing conflict in HTML with various versions of jQuery can be a powerful tool for enhancing the

Is it possible to use 2 different jQuery libraries on the same HTML page? I came across some blogs mentioning conflicts, but when I tried to add them both, I had no luck. Can anyone assist me with this? Here is my code: Product slider <link hre ...

Tips for incorporating your personal touch while utilizing Snipcart

I have created an ecommerce platform with GatsbyJS and Snipcart, but I am struggling to override the default theme provided by Snipcart. When I try to change the main default CSS through gatsby-config.js, it does not seem to work. Does anyone have a soluti ...

Troubleshooting a problem with the Bootstrap dropdown menu

Can anyone assist with an issue regarding Bootstrap 4.4.1? I am facing a problem where two consecutive dropdown links+menus are not displaying correctly. The second dropdown menu is showing the content of the previous link instead of its own, even though t ...

Transforming a menu tab into an active anchor when navigating to a particular section

Hello, I have successfully created a JavaScript code that can dynamically add menu tabs into the menu list window.addEventListener("load", () => { const navList = document.getElementById("nav_list") const fragment ...

Foundation Framework sidebar by Zurb

My current dilemma involves the zurb foundation framework, specifically with the .row class being set to a max-width of 61.25em, which is equivalent to 980px in width. The problem I am facing is that when I resize the browser and it reaches 1024px wide, t ...

What is the best way to stack a canvas box on top of another canvas box?

My goal is to have two canvas squares stacked on top of each other. While I am familiar with drawing on canvas, I need assistance in placing one canvas on top of another. Despite my attempts at setting the position, I have not been successful. <canvas ...

Ways to hide menu click when hovering over it

As a beginner, I have created a menu that shows options on hover and click. However, I am encountering an issue where clicking on one menu option and then hovering over another menu creates two lists of options. Is there a way to make the clicked menu opti ...

The React application ceases to function properly as soon as I introduce a textfield

As a newcomer to React, I am facing an issue while working on the front-end UI of a web application. Whenever I try to add a text field to the box I created, the app fails to render anything other than a blank color on the screen. Here is how it looks: W ...

Making an element sticky within a container while the parent element is set to overflow hidden

Here is a case where I have generated HTML and CSS code that includes classes for overflow, container height, and sticky positioning: .overflow-hidden { overflow: hidden; } .overflow-x-auto { overflow-x: auto; } .container { max-height: 100px; ...

What is causing justifyContent: space-between not to function properly?

I want to display Text1Text2Text3Text4Text5Text6Text7 at the top with text alignment using justifyContent: 'space-between'. However, when I tried to do so, all texts ended up at the top. <div style={{display: 'flex-item', flex: 1, ...

Incorporating Sass into Django

As I delve into my Django Project, one question looms large: where exactly should all my Sass files be placed? Is it more practical to create a central 'Sass' folder within the main Project Folder or designate a 'Sass' directory for eac ...

Leveraging the @font-face feature along with fonts sourced from fontsquirrel

As I embark on creating my very first website, I find myself delving into the world of fonts from Font Squirrel. However, a challenge arises as I realize that not all the fonts I downloaded from the site are easy to use. The real struggle comes when deal ...

I struggle with managing a z-index in conjunction with an absolute position

Check out this codesandbox to see the issue where the 3 dots button is displayed over the menu. Click on the 3 dots to understand the problem. Below is the CSS code for the menu: .more-menu { position: absolute; top: 100%; z-index: 900; float: l ...

How come an absolutely positioned element does not disregard its sibling's position and appears after it?

<div> is styled flexibly, while <section> is inserted within it and formatted statically. However, <section> shows up underneath the lower right corner of the image, rather than at the upper left corner of its flexible parent. I am strugg ...

Implement Icon using CSS Class in jQuery Mobile

Is there a way to use an icon in jQuery Mobile on a span element and also support retina display without giving the span a fixed width? Should I attempt to utilize Media Queries to achieve this, or is there an "official way" to do it? Thanks, Nils ...

Is there a way to modify the color of a checkbox within MUI?

I'm currently customizing the checkbox color in Material UI while using FormIk for data submission. I aim to change the default checkbox color to red, but I'm unsure about how to achieve this. <FormGroup> <Box display=" ...