How come the wrapper div only occupies a portion of the page even though it contains all the components?

Attempting to customize the background of a react app page, I applied styling to the main div that encompasses all components using the background property in CSS. This main div has a className called Wrapper in my app. However, the background only covers a portion of the screen instead of filling up the entire space. Here is the code snippet and visual representation:

JSX:

render() {        
        return (

 <div className="wrapper" >

    <div>Inner content</div>

</div>

) }

CSS:

.wrapper {
    overflow: hidden;
    background: linear-gradient(#42275a, #734b6d);      
}

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

The issue lies in the fact that only the top part changes color, leaving the rest of the page white.

Attempts were made like adding "height: 100%", "min-height: 100%", "height: 100vh", or "min-height: 100vh" to the wrapper class, but none resolved the issue.

Further efforts involved modifying the body property in the CSS:

body {
    background: linear-gradient(#42275a, #734b6d);  
  }

However, this resulted in an unsightly line separating the wrapper from the body as shown here: https://i.sstatic.net/WDRnW.png

The main question remains why the main div (wrapper) fails to occupy the entire screen when it contains all content extending beyond the visible area. How can the background fill the complete screen without any separation?

Furthermore, the distinct elements of the body and wrapper raise curiosity about their segmentation. The desire is for a seamless transition between these areas without any dividing lines.

Additions to the App.js file are shared below:

render() {

    if (this.state.loading) {

      return null;
    }
    else {

      return (

        <div className='app'>


          {this.state.user ?
            <LoggedIn /> :
            (<HomePage />)}


        </div >

      );
    }

}

.app {
  height: 100%
}

Code snippets from Index.js and Index.css provide additional insight:

ReactDOM.render(
  <Elements stripe={promise}>
    <BrowserRouter>
    
      <React.StrictMode>
         <ScrollToTop>
           <App />
        </ScrollToTop>                      
      </React.StrictMode>
      
    </BrowserRouter>
  </Elements>,
  document.getElementById('root')
);

html,body
{
    width: 100%;
    height: 100%;
    margin: 0px;
    padding: 0px;      
    align-items: center;  
}

A screenshot showcasing the Elements section from Developer tools is shared for reference: https://i.sstatic.net/wQj81.png

The recent removal of CSS properties from the wrapper per Dan Zuzevich's suggestion did eliminate the wrapper element, resulting in a gradient-filled screen following the body's CSS settings. Nevertheless, the screen still displays divisions or fragments instead of presenting a cohesive view. Any insights on resolving this issue? Visual representations provided below: https://i.sstatic.net/IjVZI.png

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

Answer №1

After struggling to find a solution for getting rid of some unwanted lines on my website, I finally stumbled upon the answer I needed right here - CSS3 gradient background set on body doesn't stretch but instead repeats?.

Here's the code snippet that worked like a charm:

body {
    background-image: linear-gradient(to bottom, #42275a, #734b6d);
    margin: 0;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

I hope this solution proves useful to others facing the same issue in the future.

Happy coding!

- Donald

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 parsing error when attempting to retrieve information from the database and also when utilizing the heredoc syntax

I encountered an error in my PHP project while working on a particular file: Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\x ...

Issues with implementing scrollmagic section wipe demonstration

Hey everyone, I've been trying to implement the parallax section wipe effect using ScrollMagic, following the demo from here. Unfortunately, no matter what I do, I can't seem to get it to work. It's been driving me crazy and I've spent ...

Is it possible to set a fixed height for the Material UI drawer and have it anchored at the bottom?

Is it feasible to have a material-ui Drawer anchored to the bottom of the viewport with a fixed height, and have scrollbars for additional content? <Drawer className={classes.drawer} variant="permanent" anchor="bottom" op ...

Attention: There was a prop type failure. The `game` prop type is not valid; it should be a function, typically from React.PropTypes

import React, { PropTypes } from 'react'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; // import UI components import GameList from '../components/game/GameList'; // import act ...

The issue with Nextjs getStaticPaths is that it is not retrieving data from Firebase Firestore

I'm encountering an issue with fetching dynamic data from firestore in nextjs using getStaticPaths. While rendering the data from firestore with getStaticProps works, I'm facing a problem when trying to access specific item details as it leads me ...

How to avoid displaying calculations within jsx when using React

Currently, I am in a map function where I am calculating the number of items for each category and then assigning this value to a property. The issue arises when this value is also displayed on the screen, which is something I want to avoid. ...

Which state management tool am I employing - the NEW context API or good ol' Redux?

After learning React and mastering the use of the Context API, I recently heard about a "new context api." Since I learned React from an older course in late 2017, I'm unsure whether I'm using the new or old Context API. Furthermore, upon discove ...

Update the style of a div within an iframe in React

I'm currently developing a project in Next.js and I've added an iframe within a component. The issue I'm facing is that I need to customize the style of a specific div inside the iframe, but I'm having trouble targeting the div with the ...

Experiencing difficulties with JSoup on Android for HTML parsing

I recently started working on a fun little project to scrape data (specifically XKCD comics) from the internet and display it on my phone. This is my first time delving into Android development, and since I'm not too familiar with Java, I'm keepi ...

Display the table once the radio button has been selected

Before we proceed, please take a look at the following two images: image 1 image 2 I have over 20 fields similar to 'Image 1'. If "Yes" is selected, then a table like in 'Image 2' should be displayed. This means I have 20 Yes/No fields ...

jqGrid transforming grid from HTML table using the 'settings' parameter

Understanding Hello everyone, I have come across the tableToGrid method created by Peter Romianowski as tableToGrid(selector, options) on the jqGrid wiki. However, I am unable to locate any documentation regarding the use of the options. Can anyone provi ...

The HTML5 canvas fails to render text when positioned at coordinates (0,0)

What is the reason for the canvas not displaying anything when using fillText(text, 0,0), but working properly with fillText(text, 10, 10)? fillText(text, 0,0): http://jsfiddle.net/kFhQm/4/ fillText(text, 10, 10): http://jsfiddle.net/kFhQm/5/ ...

Tips for displaying events using the start and end of the day in Recharts

Hey there! I'm looking to create a graph using the rechart library with specific x-axis labeling. I want the start of the x axis to be labeled as 12am (start of date) and the end as 11:59pm, so I can plot events throughout the day. This is how my dat ...

An automated solution designed to launch external website links in a new tab or window

I currently have a website where links open in the same window if they lead to pages on my site, and in a new window if the domain is different. However, I'm using manual code like this: <a href="http://www.example.com" target="<%=checkdomain(" ...

Do HTML sprite images load before anything on the page is displayed?

If I have a photo with sprites: When using these sprites on the website, will they appear as soon as that portion of sprites.png is loaded or will they only become visible after the entire sprites.png file has finished loading? Let's say my connecti ...

Masonry style attempted for posts but did not produce desired outcome

I've been experimenting with different methods to achieve a masonry style layout for my posts. So far, using float:left seems to work almost perfectly, but occasionally there are gaps between the posts. I'm on the lookout for a solid solution to ...

Python's find_element_by_name function appears to be malfunctioning

Just yesterday, everything was working perfectly fine. However, today I encountered this error: Traceback (most recent call last): File "bot.py", line 31, in ig_bot = InstagramBot('temp_username', 'temp_password') File " ...

Navigating with style: Mastering the art of Bootstrap 4.1's vertical navs with the mr

Why isn't 'navs' the same as 'navbar'? Learn more about navs here <ul class="nav flex-column"> <li class="nav-item"> <a class="nav-link" href="#"> <i class="fas f ...

How to align an element to the bottom using CSS without relying on the parent's height

Is there a way to align an element to the bottom of its container without knowing the exact height? I'm trying to position the "links" div next to the logo text at its bottom, but since the logo size can vary and may even be an image, setting a fixed ...

Expanding its Boundaries: React Three Fiber Canvas Overextends and Freezes

Encountering a recurring issue with react-three-fiber in multiple projects. Shown below is the structure of my current project: <div className='p-4 flex flex-col h-screen bg-primaryBackground-dark'> <div className='flex f ...