The CSS slide effect is causing an overlap with the sticky top menu bar

When scrolling, the goal is to have the menubar stick as the second div with the other divs going under it. However, only the third div, the sliding banner, is overlapping with the sticky menubar while the others are functioning correctly.

Is there anyone who can assist with this issue?

All the divs are located within the React Router.

CSS

  
      .sticky {
          width: 100%;
          height: 75px;
          color: #61dafb;
          background-color: blue;
          position: sticky;
          top: 0;
      }
      .slider-main {
          width: 100%;
          height: 500px;
          overflow: hidden;
          position: relative;
          background-image: url(../images/slide_1.jpg);
          background-repeat: no-repeat;
          background-size: cover;
          animation: slide 10s infinite;
      }
      @keyframes slide {
          0% {
              background-image: url(../images/slide_1.jpg);
              width: auto;
              height: 500px;
          }
          26% {
              width: auto;
              height: 500px;
              background-image: url(../images/slide_2.jpg);
          }
          67% {
              width: auto;
              height: 500px;
              background-image: url(../images/slide_3.jpg);
          }
      }
      /* Additional CSS code */

1st div

            
        <div>
            <div>
                PU AMD AM4 Socket for AMD Ryzen/ AMD Ryzen 2nd Generation/Ryzen with Radeon Vega Graphics/Ryzen 1st
                Generation/7th Generation A-series/Athlon X4/Athlon Processors Supports CPU up to 8 cores. The maximum memory frequency
            </div>
        </div>

2nd div

         
     <div className="mycontainer sticky">
            <Navbar className=" site-bg  " expand="lg">
                <Navbar.Brand>
                    <div>
                        <img src={logo} alt="logo" width="200" />
                    </div>
                </Navbar.Brand>
    
                <Navbar.Toggle className="border-0" aria-controls="navbar-toggle" />
                <Navbar.Collapse id="navbar-toggle" bsStyle="tabs" style={{ marginTop: 30 }}>
                    <Nav className="ml-auto">
                        <Link className="my-navbar" to="/">Home</Link>
                        <Link className="my-navbar" to="/about">About</Link>
                        <Link className="my-navbar" to="/services">Services</Link>
                        <Link className="my-navbar" to="/contact">Contact</Link>
                        <Link className="my-navbar" to="/galleries">Galleries</Link>
                    </Nav>
                </Navbar.Collapse>
            </Navbar>
        </div>

3rd div

<div className="slider-main">
        <div className="tx-anim-1">
            <div>
                Decor and Event
            </div>
        </div>
        <div className="tx-anim-2">
            <div style={{ paddingTop: 5 }}>
                A management Company
            </div>
        </div>
        <div className="tx-anim-3">
            <div style={{ paddingTop: 5 }}>
                We promise you the best Deal with full Satisfaction.
            </div>
        </div>
    </div>

4th div

            
        <div style={{ paddingTop: 50 }}>
            <Route defaultActiveKey="/home" path="/" exact render={() => <HomePage title={this.state.home.title} subTitle={this.state.home.subTitle} text={this.state.home.text} />} className="container-full" />
            <Route path="/about" render={() => <AboutPage title={this.state.about.title} subTitle={this.state.about.subTitle} text={this.state.about.text} />} />
            <Route path="/services" render={() => <ServicesPage title={this.state.services.title} />} />
            <Route path="/contact" render={() => <ContactPage title={this.state.contact.title} />} />
            <Route path="/galleries" render={() => <GalleriesPage title={this.state.galleries.title} />} />
            <Footer />
        </div>

Answer №1

Dealing with the issue of stacking order, also known as the z-index problem, can be easily resolved through CSS. By applying the following CSS properties to your classes, you can effectively manage this issue. I have also included background-color to ensure that elements are displayed correctly, particularly when dealing with overlapping elements such as sticky menus and sliders.

.mycontainer{
    z-index: 100;
    background-color: skyblue;
}

.slider-main {
    z-index: 101;
}

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

Adapting the colors of various elements throughout the entire webpage

My goal is to incorporate color-switch buttons on my webpage. When these buttons are clicked, I want the existing colors to change to different shades. However, my challenge lies in the fact that these colors are used for various elements such as backgro ...

Customizing Ngx-bootstrap Carousel Indicator, Previous, and Next Button Styles

<carousel > <a href=""> <slide *ngFor="let slide of slides"> <img src="{{slide.imgUrl}}" alt="" style="display: block; width: 100%;"> </slide> 1. Is there a way to substitute the indicators with images ...

Is there a way to store image URLs in a fashionable manner?

Hey there! I've been working on creating a HTML page that showcases multiple images. Everything is running smoothly on my localhost, but when I try to access it online, the images take forever to load. Any suggestions on how I can cache image URLs in ...

What is the best way to shorten string values that exceed a certain length?

Here is an array list I have: $myarray = array( array( 'name' => 'File name 1 - type.zip', 'size' => '600KB', ), array( 'name' => 'File name 2 - type.pdf&a ...

Error: "Bootstrapsudio is experiencing a missing option in the col-md-

Recently, I was following a tutorial on Bootstrap Studio that showcased the design of a bakery named "Mom & Pop's Bakery". The tutorial highlighted how we could adjust the size of a column within a container by manipulating the column size on the righ ...

Establish height and width parameters for creating a dynamic and adaptable bar chart with recharts

I am currently facing an issue with recharts while trying to implement a BarChart. The setting width={600} and height={300} is causing the Barchart to be fixed in size, rather than responsive. How can I make the BarChart responsive? I attempted using per ...

The sticky header is malfunctioning due to a null offsetTop value

import React , {useRef, useEffect} from 'react' import './header.css' const nav_links =[ { path:'#home', display:'Home' }, { path:'#about', display:'About& ...

Applying different styling to the same class within a different element using the + selector

Have you ever come across a website with code similar to what I've shared on this jsfiddle: https://jsfiddle.net/roa8k7js/ This particular site boasts an elaborate CSS styling sheet, exceeding 10,000 lines in length. When transitioning this website t ...

State remains stagnant following update from use state

Recently diving into React, I've been experimenting with getting my socket io listener up and running smoothly. Interestingly, when I have it placed outside of the useEffect, it seems to function but gets called multiple times. However, when nestled w ...

Navigating through sibling elements can be accomplished by using various methods in

Can someone help me figure out how to assign unique IDs to 6 different Div elements as I step through them? The code snippet below is not working as expected, giving all Divs the same ID. What is the correct way to accomplish this task? $('#main-slid ...

Bringing SASS Bootstrap into a React project

After following the instructions in the Bootstrap documentation here to install Bootstrap via Webpack, I attempted to import the CSS styles as outlined here. However, I encountered a problem when trying to add the import (@import "node_modules/bootstrap/sc ...

Issue with React Routes only occurring in the production website

I'm encountering an issue on my personal website that only occurs in production, but not in my local environment. Here's the situation: I have set up the routes as follows const Routes = () => ( <Router> <Route exact path=&quo ...

What is the best way to retrieve the URL of a website using scrapy?

Currently, I am faced with the challenge of scraping the Amazon website using Scrapy. While I have successfully extracted items like product titles and prices, I am struggling to figure out how to extract the URL of a product (as shown in the image at the ...

Disorderly arrangement of HTML elements

I'm facing some issues with the page layout as I have to use a combination of tables and divs. The main problem arises with the footer and the div containing the table. Despite the fact that the footer is the last element inside the "main_container" i ...

Tips for utilizing the font-family style to span multiple columns

I recently discovered that you can set the background color across table columns using the <colgroup> tag. table { border: 2px solid; border-collapse: collapse; } td { border: 2px solid; } <ta ...

Styling anchors that are focused or visited while scrolling using CSS and jQuery

I'm facing a challenging question that I can't seem to figure out on my own. At the top of my page, I have some anchors that smoothly scroll down to different articles: I would like to indicate to visitors their location on the page by rotating ...

Ways to prevent react-p5-wrapper from continuing to run in the background

I encountered a problem with react-p5-wrapper where it continues to run in the background even after switching to another route in my react application. For instance, while I am on the /game route, the console keeps logging "running draw". Even ...

Guide to setting up Bootstrap-4 on Laravel 5.5 with Composer

I started a new Laravel project by running the following command: composer create-project --prefer-dist laravel/laravel myProject Following that, I added Bootstrap-4 to my project using: composer require twbs/bootstrap:4.0.0-beta.3 The Bootstrap distri ...

Tips for maintaining the default page size on your website when adjusting the browser window size

I've been struggling with a problem for quite some time now. How can I maintain the default page size of my website while resizing the browser? Let's assume the page size is 1280x720, how do I ensure that size remains intact when I adjust t ...

What is the best way to remove the underline in Material-UI while still keeping the selection feature intact in Autocomplete?

Seeking to develop an Autocomplete feature with the TextField component while eliminating the underline. I successfully disabled the underline by utilizing InputProps={{ disableUnderline: true }} in the TextField properties, however, it also eliminated t ...