Arranging divs in succession using CSS positioning

Struggling to design a landing page with a fixed background slideshow followed by a div explaining the website's purpose, I encountered an issue where the two divs overlap due to the current HTML and CSS code.

Even after experimenting with different position properties and setting the parent div as relative with the child divs also as relative, the problem remains unresolved.

.crossfade>figure {
  animation: imageAnimation 30s linear infinite 0s;
  backface-visibility: hidden;
  background-size: cover;
  background-position: center;
  color: transparent;
  height: 100%;
  left: 0px;
  opacity: 0;
  position: absolute;
  top: 0px;
  bottom: 0;
  width: 100%;
  z-index: -1;
  min-height: 700px;
  background-attachment: fixed;
  background-repeat: no-repeat;
  background-size: cover;
}

#landing {
  position: absolute;
  top: 500px;
}
<div className="main">
  <div class="crossfade">
    <figure></figure>
    <figure></figure>
  </div>
  <div id="landing">
    <div className="container">
      <img />
    </div>
    <p> Hello </p>
  </div>
</div>

The desired outcome is to have the two divs display sequentially without overlapping, with the top background image slideshow intact and the second div following suit.

Answer №1

It appears that the initial part of your CSS pertains to the <div class="crossfade">. The issue may lie in both the crossfade and landing <div>'s having a position: absolute, which could be causing them to overlap.

If you desire for the crossfade and landing elements to be positioned side-by-side or top-to-bottom, my suggestion would be to enclose both within an outer <div> and utilize Flexbox.

.outer-container {
    display: flex;
    width: 100%;
    text-align: center;
    justify-content: center;
    align-items: center;
    
    /* To have them appear top to bottom, you can enable this line. */
    /* flex-direction: column; */
}

.crossfade, #landing {
    /* Adjust the width as needed based on margins, padding, and other dimensions. */
    width: 45%;
    height: 100px;
    border: 1px solid black;
}
<div class="outer-container">
    <div class="crossfade">Crossfade</div>
    <div id="landing">Landing</div>
</div>

Additionally, could you elaborate or provide an example regarding this statement:

while preserving the top background image slideshow and then showing the second div

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

Using CSS to create animation delays for several div elements sharing the same class

I have a project in progress where I need to load multiple divs with a small animation. However, in the provided fiddle, they all load simultaneously. Is there a way to make them load one after another with a 0.1s delay? http://jsfiddle.net/HaQmN/38/ App ...

Struggling to change defaultValue using onChange in a React.js app connected to Firebase

Currently, I am creating a dynamic form that is rendered using map. I have successfully updated all the values into a dictionary and stored them in Firebase. Now, when I submit the form, I need to display the stored values as the default input values. con ...

iPhone Safari Mobile Browser experiencing issues with sms: and mailto: functionalities

Issue: Encountering a problem with web pages containing sms: and mailto: links not functioning on iOS mobile Safari browser. Clicking on the link redirects to: Safari cannot open the page because it cannot redirect to locations starting with "sms:& ...

Tips for ensuring your webpage stays current with regular updates through JavaScript

This webpage acts as a dynamic newsboard, constantly updated with the latest data from my Database through an API, all without requiring a page refresh. While the timer solution seemed simple, I am seeking a more resource-efficient approach. I have resear ...

What is the best way to find an element using either 'className1' or 'className2'?

Within my project, all locators are defined as elements of an enum and follow this format: For example, if it is a CSS locator - DIV_LOCATION("css=div.location-text.text-overflow"). This method parses the string and identifies it as a CSS locator if it be ...

How come the icon doesn't update on the client side after being rendered on the server side?

Currently implementing a Daisyui theme switcher in my nextjs project. It's mostly working fine, but there are some issues I'm having trouble with. I've created a simple theme switch button: // Themeswitch.jsx 'use client'; impor ...

What is the best way to display an HTML element fetched from an API response?

I am experiencing difficulty in rendering a tag from a response. Instead of rendering it as HTML, it displays as text. Internet currency makes mobile payments easy, with very low transaction fees and protection of your identity. It operates without the ne ...

Is Bootstrap 4.0.0 not compliant with W3C standards?

I'm struggling with an issue in my application where I am attempting to minimize all of my .css files. It appears that Bootstrap is not passing W3C validation, both in the regular and .min versions. Any insights on how to resolve this issue? ...

Incorporating CSS styling dynamically using Javascript

Just a heads up - I am completely new to coding and JavaScript, and this happens to be my very first post, so please bear with me. I have a set of Hex codes representing various colors, and my goal is to utilize JQuery to style some empty divs in the HTML ...

React: Struggling to Get Margins Right for Navigation Bar Spacing

I recently tried my hand at following a tutorial for building a React app: React JS Tutorial for Beginners #1 – Build a website using React, Sass, Gulp and Node.js After completing the tutorial, everything seemed to be working smoothly except for one th ...

The symbol '★' represents the '★' content in CSS

Here is the CSS code I am using: .rating:not(:checked) > label:before { content: '★'; } However, when it is displayed on the screen, instead of seeing a ★, I see â˜. It's strange because if I use Firebug and manually change the ...

Resizing an HTML table causes the background to break

I have incorporated a tailwind table with a max-width setting. In my html, I am utilizing the default Laravel Jetstream layout. However, I am facing an issue wherein the background doesn't repeat in the browser when trying to use the scrollbar on sma ...

Designing a webpage visitor tracker using the innerHTML attribute

I'm currently working on a webpage that tracks the number of times it gets loaded and displays this count to users. I am using localhost MAMP for testing. Check out the code snippet below: <html> <head> <title>Test Page</titl ...

What is the reason for the index.html file not connecting to the local .css files and .js file?

I'm currently using node.js to send an .html file that includes the following tags: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="description" content="This is my personal profile website" /> <link r ...

Saving the order of elements dropped in jQuery UI Droppable into an input field

Link to setup: https://jsfiddle.net/7b8bqzsh/1/ You can view a full working example using the link provided above. The objective is to store the order of the links in an input field so that it can be saved to a database. Currently, only the latest ID is ...

Remove newline character from HTML code using Python 3.2 and urllib module

After fetching HTML content as a string using urllib, I encountered difficulty in searching the string due to its HTML format. Is there any way to "unformat" the string by removing all the new lines without altering the HTML code itself? Here is the Pytho ...

When utilizing Axios to download a video from an API within a React application, an issue arises where an empty mp4

Question: My backend API successfully returns a video (verified via Postman), but when I try to implement a "download video" button, it downloads an empty file. I've attempted several different implementations with no luck. Below is my current code: ...

Allow a single component to showcase information from two separate API calls

My React application utilizes Redux to fetch data from an API. Within the app, there is a component that appears twice on the same page. This particular component is connected to both an action and a reducer. The challenge I am facing is that each instanc ...

The information is failing to display properly within the mat-menu

Recently, I've been working on creating a navbar that includes a submenu. Even though the navigation bar data is loading properly, I am facing some issues with the submenu functionality. As a beginner in this area, I would appreciate any help or guida ...

Is it possible to eliminate the sticky class as you scroll down?

Check out this jQuery code I wrote to remove the sticky class while scrolling down: $(window).scroll(function (e) { if ($('.main_form_wrapper').length != 0) { var window_scroll = $(window).scrollTop(); console.log(window_scro ...