The background of the section does not extend to the full height

Currently, I am using the <section> tag as a background for a specific section on my website. However, I am facing an issue where the height of the background is being cut off, even though the content continues below it.

I have attempted various positioning methods to resolve this issue but none of them have been successful.

#pipe{
    background-image: url('https://via.placeholder.com/1000');
    width: 100%;
    height: auto;
    background-size: cover;
    background-repeat: no-repeat;
    padding: 50px;
}
#pipe .starter-right{
    width: 60%;
    height: 30em;
    background-color: rgb(138, 138, 138, 0.7);
    float: right;
}

#pipe .second-left{
    margin: 250px 0;
    width: 80%;
    height: 40em;
    background-color: rgb(100, 100, 100, 0.7);
    float: left;
}
#pipe .third-right{
    margin: 50px 50px;
    width: 80%;
    height: 35em;
    background-color: rgb(80, 80, 80, 0.7);
    float: right;
}
#pipe .four-left{
    margin: 200px 50px;
    width: 80%;
    height: 75em;
    background-color: rgb(50, 50, 50, 0.7);
    float: left;
}
    <section id="pipe">
            <div data-aos="flip-left" data-aos-duration="1000" class="starter-right">
                <h1>About</h1>
            </div>
            <div data-aos="flip-right" data-aos-duration="1000" class="second-left">
                <h1>More content</h1>
            </div>
            <div data-aos="flip-left" data-aos-duration="1000" class="third-right">
                <h1>More content</h1>
            </div>
            <div data-aos="flip-right" data-aos-duration="1000" class="four-left">
                <h1>More content</h1>
            </div>
            background ends here
    </section>

I would like to understand why the background is not covering the entire height of the section and how can I ensure that it does so?

Answer №1

By floating the descendants of your section, you are effectively removing them from the flow of the document. To bring back the behavior you desire, simply add overflow: auto; to your section.

#pipe {
  background-image: url('https://via.placeholder.com/1000');
  width: 100%;
  height: auto;
  background-size: cover;
  background-repeat: no-repeat;
  padding: 50px;
  overflow: auto;
}

#pipe .starter-right {
  width: 60%;
  height: 30em;
  background-color: rgb(138, 138, 138, 0.7);
  float: right;
}

#pipe .second-left {
  margin: 250px 0;
  width: 80%;
  height: 40em;
  background-color: rgb(100, 100, 100, 0.7);
  float: left;
}

#pipe .third-right {
  margin: 50px 50px;
  width: 80%;
  height: 35em;
  background-color: rgb(80, 80, 80, 0.7);
  float: right;
}

#pipe .four-left {
  margin: 200px 50px;
  width: 80%;
  height: 75em;
  background-color: rgb(50, 50, 50, 0.7);
  float: left;
}
<section id="pipe">
  <div data-aos="flip-left" data-aos-duration="1000" class="starter-right">
    <h1>About</h1>
  </div>
  <div data-aos="flip-right" data-aos-duration="1000" class="second-left">
    <h1>More content</h1>
  </div>
  <div data-aos="flip-left" data-aos-duration="1000" class="third-right">
    <h1>More content</h1>
  </div>
  <div data-aos="flip-right" data-aos-duration="1000" class="four-left">
    <h1>More content</h1>
  </div>
  background ends here
</section>

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

Troubleshooting common issues with PHP's simple HTML DOM parser

I've encountered an issue while working on a scraper for a website that involves crawling through links. The error message I'm receiving is as follows: PHP Fatal error: Uncaught Error: Call to a member function find() on null in D:\Projekti ...

Activate validation checks when the Div is loaded

I have a situation where I have multiple divs on my page, with only one visible at a time due to the use of an update panel. Within the third div, I need to implement validations using jQuery. <script src="http://ajax.aspnetcdn.com/ajax/jquery.valida ...

Authenticating the Gmail API using a specified user ID

Is there a way to manually input email and password for authentication in the Gmail API without using the default Google popup? I need users to enter their login credentials directly, but I can't figure out how to do it. The code I am currently using ...

The data type "100%" cannot be assigned to a number type in the kendo-grid-column

I need the columns in the grid to have a width of 100%. <kendo-grid-column field="id" title="id" [width]="'100%'"> </kendo-grid-column> However, when I hover over the code, I get this message: The value "100%" cannot be ...

What is the best way to increase the font size without resizing the parent input element?

Is there a way to increase the font size in this text box without enlarging the box itself? Any suggestions or advice would be appreciated! https://i.sstatic.net/91pon.jpg. Below is my CSS code for reference (the class of the form is 'box'). .bo ...

jquery to create a fading effect for individual list items

I have a group of items listed, and I would like them to smoothly fade out while the next one fades in seamlessly. Below is the code I've been working on: document.ready(function(){ var list_slideshow = $("#site_slideshow_inner_text"); ...

The Eclipse IDE is experiencing issues with the functionality of the JavaScript Number class

In my latest project, I decided to create a Dynamic Web Project using the Eclipse IDE 2019-12 along with Apache Tomcat 8.5.55 server. The main functionality of this project is that a user can input integers and receive their sum as an output. To ensure dat ...

Struggling with converting my menu design into a dropdown menu

Recently completed creating my initial menu with a left navigation bar design. Wondering if it is achievable to implement a dropdown effect on hover without the use of javascript? I have come across several solutions but they do not seem to work for me, po ...

Troubleshooting spacing and padding problems in Bootstrap 5.2.3's Scrollspy feature

Hello, I'm currently working on developing a new portfolio template that features a list on the left side to guide users through different sections of the page. Utilizing Scrollspy in Bootstrap 5.2.3 has been helpful so far, but I've noticed that ...

Using Angular 4 constructor value in a condition with *ngIf

Within this TypeScript snippet, there is a variable called moreinfo that is initially set to 1. In the constructor, however, the value of moreinfo is changed to 2. Subsequently, based on whether the value is 1 or 2, different div elements are displayed usi ...

Image showcasing the background

I'm facing an issue with adding a background image to my project Even after trying to add it globally, the background image is not showing up on the Next.js index page. import { Inter } from 'next/font/google' const inter = Inter({ subsets: ...

Ways to avoid divs overlapping on a mobile device?

If you visit this page: The recent searches section displays correctly on a computer, but it overlaps with the footer when viewed on an iPhone 6. What steps can I take to avoid this issue? ...

How can I use JavaScript and HTML to print a canvas that is not within the print boundaries?

As someone who is new to javascript, I recently created a canvas function that allows me to successfully print. However, I am encountering an issue with printing large canvas areas. When I navigate to the further regions of the canvas and try to print, i ...

How do I eliminate excess space following the resizing of the Material UI Drawer component?

I adjusted the size of my MUI drawer to a specific width and now I am facing an issue where there is extra space left after resizing. This results in a margin-like space between the drawer and the Lorem Ipsum text content. My goal is to eliminate this rema ...

Angular4: The Process of Iterating Through an Array of Objects within an Object

I'm struggling to iterate through an Object that contains an array of objects within an anchor tag. Here's how my code is structured: {"1":{"uri":"test1","name":"test1","icon":"http:\/\/dummyurl\/images\/icons\/test1-ico ...

Is there a way to automatically add a div to the window as the user scrolls and then hide the div when they scroll back to the

Seeking assistance with creating a function that will add a 'sticky' class to the menu when the user scrolls down to the middle, and then append a div when the 'sticky' class is present. Currently facing issues where the div keeps appen ...

The React style background property for CSS styling

Is there a way to apply the css property background inline in react? I attempted to pass the following object without success: let style = { background: `linear-gradient( rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6) ...

Lost item phenomenon: conceal information below until it emerges

I'm attempting to create a garage door effect on my website, where upon loading the page, a garage door is displayed. Upon hovering over the door, it lifts up to reveal the content behind it. The challenge I'm facing is keeping the content hidden ...

Learn how to divide a container div with multiple sub-divs into two columns using CSS

Are you up for a good challenge? In my MVC project, I have a dynamic list of divs that I want to split into two columns. The number of divs in the list is unknown. How would you go about achieving this task? EDIT: Just to clarify, when I say split, I&a ...

A gap only appears in the drop-down navigation when the page is scrolled

After finally completing my first website, I encountered a frustrating issue. When scrolling down the page, a gap appears in the navigation bar, making it impossible to access the dropdown menus. I've been struggling to fix this problem on my own. Any ...