sticky icon or footer attached to bootstrap modal

I'm encountering an issue with my sticky footer in a modal. I have a modal that contains an input field with overflow, and I want to ensure that a sticky div inside the modal always stays at the bottom of the screen. Specifically, I am trying to achieve the following: On mobile devices, I want the div to be positioned at the very bottom. I've tried implementing solutions from various sources but none seem to meet my requirements. My goal is to have the div move above the keyboard when someone focuses on the input area (which triggers the keyboard to display on mobile devices).

Here is my current code:

   <Modal
        show={show}
        onHide={() => setShow(false)}
        centered
        fullscreen="lg-down"
      >
        <div className="sticky-container"> {/* This should stay sticky at the bottom */}</div>
        <Modal.Header closeButton>
          <Modal.Title> Create a post </Modal.Title>
        </Modal.Header>
        <Modal.Body>
          <div>
            <div className="blog-form p-3">
              <Form onSubmit={addBlog}>
                <Row className="mb-1 body-container">
                  <Row>
                    <Form.Group
                      as={Col}
                      className="mb-3"
                      controlId="blog-description"
                    >
                      <Form.Control
                        className="description-input"
                        style={descriptionFont}
                        value={description}
                        as="textarea"
                        // Adjust the number of rows as needed
                        placeholder={placeholder}
                        onChange={(event) => handleTextAreaChange(event)}
                        autoFocus
                      />
                    </Form.Group>
                  </Row>
                  <Row>
                    <Col>
                      another div here
                    </Col>
                  </Row>
                </Row>
               
              </Form>
            </div>
          </div>
        </Modal.Body>
        <Modal.Footer>
          <Button type="submit" onClick={addBlog}>
            Submit
          </Button>
        </Modal.Footer>
      </Modal>
    </>

along with the current styles:

.blog-form {
  max-height: 500px;
  overflow-y: auto;
}

.blog-form textarea {
  width: 100%;

  /* Set a minimum height for the textarea */

  resize: none; /* Disable manual resizing */
  overflow-y: auto;
}

.body-container {
  padding-top: 10px;
  display: flex;
  overflow-y: auto;
}

.sticky-container {
  height: 40px;
  background-color: blue;
  position: sticky;
  bottom: 0;
  z-index: 1055;
}

view on stackblitz

Answer №1

If you're looking to experiment with bootstrap's modals, here is a potential solution:

        .container {
            width: 300px; /* Adjust width as needed */
            height: 400px; /* Adjust height as needed */
            border: 1px solid #ccc;
            
            position: relative; /* Establish container as positioning context */
        }

        /* Body styles */
        .body {
            height: 100%;
            overflow-y: scroll; /* Allow vertical scrolling in body */
            padding: 10px; /* Add padding for content within body */
        }

        /* Sticky div styles */
        .sticky-div {
            position: sticky;
            bottom: 0;
            background-color: #f0f0f0; /* Define background color for sticky div */
            padding: 10px; /* Add padding to sticky div */
        }
    

Check out this Jsfiddle link

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

Stop vuetify from cluttering the global style scope

Seeking to embed a Vue component into another from an external source without using a Vue Plugin. The components are mounting correctly, but the embedded component's use of Vuetify is affecting the parent application's style. Visual examples can ...

Issue with text-nowrap not functioning as intended within Bootstrap 4.5 table cells

Is there a way to eliminate the space between two columns in my layout? I want to get rid of the highlighted space below. I attempted using text-nowrap, but it didn't achieve the desired result. <link href="https://stackpath.bootstrapcdn.co ...

Trouble with importing scss file in sass and bootstrap collaboration

I am using Sass with Bootstrap 4, and now I'm facing an issue in my Sass folder where I have an app.scss file that includes: @import _customVariables.scss @import node_modules/bootstrap/scss/functions @import node_modules/bootstrap/scss/mixins Howev ...

Corner of the Border Revealing a Clear Sky above

Looking to enhance my navigation bar (menu) by adding a cornered border when the user hovers over it. <nav> <a href="#home">Home</a> | <a href="#about">About</a> | <a href="#blog">Blog</a ...

Create a sleek and innovative tree user interface in a single line with the power of Angular and fxF

I created a tree with parent and child nodes, but I'm facing an issue where the positions of the checkboxes are not aligned in a straight line. Here is my code snippet: <mat-tree-node *matTreeNodeDef="let node" matTreeNodeToggle> ...

Tips for ensuring the final row remains fixed at the bottom of the table while maintaining a minimal body height:

I'm currently working on designing an invoice table using HTML and CSS. I have dynamic rows that are added to the table, and I want the body of the table to have a minimum height to fit around 5-6 rows, after which it should extend based on the number ...

Can the `resize` CSS property be applied to the `body` element in HTML?

Check out my website which currently has a fixed max-width. I am interested in enhancing the user experience by adding a draggable border to the sides, allowing users to adjust the width based on their preference. Many online suggestions involve complicate ...

What is the best method for adding or removing items using ID instead of classes?

Is there a way to change the highlight class to an id, so that clicking outside the products will not trigger the highlight effect? I have added the window.onload section with my desired changes, but I am unsure how to switch the class highlight to an id. ...

Issue with CSS not appearing in Google Chrome's coverage tab

As I delve into analyzing the extent of unused CSS on my webpage, I encounter a challenge. The webpage is crafted in Angular 7, with CSS incorporated through the angular.json build configuration. The css appears to be added to the head of the html file, e ...

Is it possible to add some color to the first table in the div

Is it possible to change the background color of the first table within this Div tag that contains three tables? <div id="WebPartWPQ2" width="100%" HasPers="false" allowExport="false"> <table width="100%" border="0" cellSpacing="0" cellPadding= ...

There seems to be an issue with the functionality of Angular Material on iOS devices

I recently developed a website using Angular and Angular Material. While the site functions properly on Windows and Android across all browsers, I encountered an issue with iOS devices running Safari. Some elements on the page do not display correctly on i ...

Issue with Photoswipe pswp class Not Getting Properly Cleared Upon Closing Image

My website has a Photoswipe image gallery from . The issue I'm facing is that the CSS class does not reset or clear after closing the gallery for the second time. For example, when a user opens item 1, the images are loaded into the picture div via A ...

Locate a specific class inside a div and switch the CSS style to hide one element and reveal another

I have two divs, each containing a span. By default, the display of each span class is set to none. My goal is to toggle the display property of the span within the clicked div. If the span is already visible, I want to hide it; if it's hidden, I want ...

How to make Vuetify grid columns wrap and fill the full height

I am facing an issue where the component created using v-card in a grid system does not fill the full height. I tried using d-flex but it did not work as expected. The middle column with a white v-card should occupy the entire column height but it is gett ...

The gaps separating rows

I'm struggling with getting my divs to look like a table, especially when it comes to highlighting a selected row. I've tried adjusting padding and margins without success. Does anyone have any suggestions on how I can achieve this effect? .ta ...

How to create list item bullets with a star icon using reactstrap/react?

As a machine learning professional looking to enhance my frontend skills, I am curious about how to create list item bullets using a custom star bullet image. Could anyone please share a complete HTML/CSS example with me? Thank you in advance! ...

Adjusting the height of the Owl Carousel div to enhance image hover effects

Seeking help with implementing a hover effect on an img within an Owl Carousel div. I have applied a simple CSS transition to the Owl Carousel container div, but the Carousel is automatically setting a standard height. Images included for reference. I have ...

What are the methods for choosing various boxes using the UP/DOWN/RIGHT/LEFT arrow keys?

This code snippet displays a 3x3 matrix where boxes can be hovered over and selected. The goal is to navigate around with keys and select boxes using ENTER. Can anyone provide guidance on how to achieve this functionality? <link rel="stylesheet" href ...

I specialize in optimizing blog content by omitting the final line within a React framework

https://i.stack.imgur.com/WKOXT.png Currently, I have 4 lines and the 5th line in the current input field. This is my React code snippet: import { FC, useEffect, useState } from "react"; interface BlogWitterProps {} const BlogWitter: FC<B ...

What could be causing the absolute positioned element to not follow the positioning rules as expected?

Currently, I am following a guide on creating a website using Dreamweaver (). However, I have encountered a step in the tutorial that I am struggling to comprehend. The issue lies with an element named #navlink, which is absolutely positioned in the DOM s ...