React component causing footer overlap

Currently, I'm facing a challenge in creating a footer that stays at the bottom of the page without overlapping any other components.

In my index file, I've included the following code:

.footer{
  margin-top: 1rem;
  padding: 1rem;
  background-color: #3D938B;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
}

I have treated the footer just like any other component on the page...

<Router>
  <NavBar></NavBar>
  <div className={classes.topMargin}>
    <Route exact path="/contact-us" element={<ContactUs/>}/>
  </div>
  <Footer></Footer>
</Router>

The CSS for my contact-us page is as follows:

@media only screen and (max-width: 700px) {
    .form-container {
        text-align: center;
    }
    .button-submit {
        background-color: white;
        width:7rem;
        border-radius: 10px;
        border: 2px solid #3D938B;
        color: #3D938B;
        padding: 5px;
        margin-bottom:20px;

    }
}

Your help with this matter would be greatly appreciated!

Answer №1

If you want to ensure your footer stays at the bottom of the page without overlapping other elements, you can use this helpful CSS code snippet.

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#footer {
  background-color: #3D938B;
  flex: 0 0 50px;
  margin-top: auto;
}

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

How can I incorporate dashed borders between images using CSS?

New to the world of HTML and CSS, I'm trying to replicate a design I came across online for some practice. The website layout includes images separated by borders, and I'm unsure if this particular design can be achieved using regular CSS alone o ...

Designing numerous vertical lists in HTML

I need help with displaying multiple lists vertically using HTML For example: +--------+---------------------------------------------+--+ | Global | Region Country Currency Account Type Entity | | +--------+---------------------------------------------+ ...

Tips for assigning information from a react hook within a function or event

Currently, I am in the process of learning how to create hooks in order to efficiently reuse data that needs to be modified across different components. For my project, I am utilizing Material UI's Tabs and require the use of a custom hook called use ...

WordPress CSS Styling Issue: HTML Element Display Problem

I recently converted my static HTML site to WordPress, but I'm facing an issue where the site is always aligned to the left. Despite trying different solutions like the one below: body{ margin: auto; } The original HTML page was centered perfectly ...

The JWT token will expire if the user logs in from a different browser

My application generates a JWT token for the user when they log in, but I am facing an issue. I want the user to be automatically logged out from their first device or browser when they log in from another one. Unfortunately, I have not been able to find ...

The HTML elements in my JSX code seem to constantly shift around whenever I resize my webpage

Using react.js, I'm currently developing a website that appears like this before resizing: pre-resize_screenshot_website However, upon vertical or diagonal resizing, the layout becomes distorted especially in the 'availability search bar' ...

The CSS property for restricting white-space to nowrap is not functioning as

Having a div with multiple child divs floating left can be tricky. To prevent them from breaking, setting them to display:inline-block and white-space:nowrap seems like the solution. However, in some cases this may not work as expected. If your goal is to ...

Sharing information between React components involves passing data as props. By sending data from

Brand new to React and still figuring things out. Here's the scenario: <div> <DropDown> </DropDown> <Panel> </Panel> </div> After selecting a value in the dropdown and storing it as currentL ...

Hierarchical ordered list with Material UI styling

I wanted to create a list in the following format: 1. xxxxx 2. xxxxx a. xxxxx b. xxxxx 3. xxxxx 4. xxxxx a. xxxxx b. xxxxx The data for this list will be sourced from a react state variable and will need to be mapped accordingly. The exact str ...

Typescript enums causing Safari to display blank screen in Next.js

The website performs well on Chrome and Edge, but encounters difficulties on Safari for iOS. Although all the elements, styling, and scripts load properly, nothing appears on the screen. After spending countless hours debugging, I discovered that the pro ...

Parent component experiencing delays while updating React state

As I work on my react application, I've always believed that state updates in react happen quickly. However, I've come across a problem recently. In one of the pages of my application, there are multiple elements present. One particular element ...

Add an additional Node.js module to the ReactJS project

Exploring the world of reactJS/Node as a newbie, I embarked on creating a project using npx create-react-app myapp. After some time spent experimenting, I stumbled upon "material-ui". Intrigued, I decided to incorporate it into my project by running npm i ...

Retrieve information from a .json file using the fetch API

I have created an external JSON and I am trying to retrieve data from it. The GET request on the JSON is functioning correctly, as I have tested it using Postman. Here is my code: import "./Feedback.css"; import { useState, useEffect } from " ...

The Order of Transitions Reversed in CSS

I have a unique situation that I'm hoping to get some help with. I've been trying to create an effect where I move text away and lift up a gray box, and then when my mouse moves away from the gray box, the box goes down first before the text move ...

Issue with resolving the '@/theme' module while using Material UI with Nextjs

As a newcomer to MUI, I am facing an issue with the material-ui-nextjs app router example. After setting up the project, I encountered an error when trying to import the theme module - "Module not found: Can't resolve '@/theme'". Below are s ...

Updating the list in React upon form submission without requiring a full page refresh

Currently, I have a list of data being displayed with a specific sort order in the textbox. Users are able to modify the order and upon clicking submit, the changes are saved in the database. The updated list will then be displayed in the new order upon pa ...

Altering the background color of :after while :before is being hovered over

Is it possible to modify the :after section when hovering over the :before part? Take a look at this image for reference: I want to alter the small triangle shape when the large square is being hovered over. The square uses the :before pseudo-element and ...

CSS - Problem with background image appearing stretched on Samsung mobile devices

Is the Samsung default "Internet Browser" based on another build? It seems to have trouble displaying stretched background images correctly, unlike desktop browsers or Chrome for mobile. Here is the CSS and HTML I am using: #bk_img { height:100%; ...

Expand the background of columns to cover grid gutters

Imagine this... You're working on a layout with three columns, all within a fixed-sized container that is centered using margin:0 auto. The design requires the first column to have a background color that reaches the left edge of the browser window. ...

Connecting the material-ui dropdown to a table

Is there a way to connect a react material-ui dropdown to a table? I am working on a project where I have a drop-down list containing countries and a table displaying country names and their corresponding capital cities. The goal is to update the table b ...