Unwanted overlapping of JavaScript image slideshow animation on top of the website's header

Situation/ Issue The picture slide animation box on my website is positioned just below the fixed header. The problem arises when I try to change the image using the left and right arrows. During the transition, a part of the hidden image becomes visible and overlaps with the fixed header temporarily before going behind it again.

How can I prevent this overlapping behavior and ensure that the picture box always stays behind the header?

The picture slide animation feature on the site is adapted from the following source:

The structure of my header.php file is as follows:

<header> 
<img  src="img/logo.png" width="400" height="120" alt="site logo"/>

            <ol >
                <li class="menu"> <a  href="index.php">Home</a> </li>   
                <li  class="menu"> <a href='about.php'>About This site </a> </li>   
                <li  class="menu"> <a href='learn.php'> Learn</a> </li>   
                <li  class="menu"> <a href='sponser.php'> Sponsor Me </a></li>     
            </ol>   
</header>
  1. CSS for header

    *{
        padding:0;
        text-decoration: none;   
    }
    
    header{
        background-color: white;
        color: white;
        position:fixed;
        top:0;
        border-bottom:1px solid #1e204c;
        display: block;
        width:100%; 
    }
    ol {
        display:inline-block; 
    }
    a:link{
        color:black;
    }
    
    .menu{
        display:inline-block;
        font-size:16px;
        font-family: 'Roboto', sans-serif;
        padding:0px 40px 0px 40px; 
        position:relative;
        bottom:30px;
        left:700px   
    }
    

If you prefer not to visit the link provided, here are my customized HTML markup and script:

  1. HTML

    Enter code here

      <?php include 'header.php'; ?>
      <!--photos-->    
      <div class='main'>
    


    1 / 3</div>--> caption

    2 / 3</div>--> caption

    3 / 3</div>--> caption

    ❮ ❯

        <div style="text-align:center">
       <!-- span is an inline version of a div-->
    <span class="bulletIndicators" onclick="currentSlide(1)"></span> 
    <span class="bulletIndicators" onclick="currentSlide(1)"></span> 
    <span class="bulletIndicators" onclick="currentSlide(1)"></span> 
    

  2. CSS for image slides

    .mySlides { height:400px; width: 100%; overflow:hidden;

    } /* Next & previous buttons */ .previus, .next { cursor:pointer; position: absolute; top: 300px; padding: 16px; color: white; font-weight: bold; font-size: 18px; overflow:hidden;

    /* allows for a change in property within a given timescale Ease specifies a type of transition which starts and ends slow but speeds up somewhere in the middle of the timescale. */ transition: 0.6s ease; border-radius: 0 3px 3px 0; }

    /* Position the "next button" to the right */ .next { right: 2px; border-radius: 3px 0 0 3px; }

    .previus{ left: 2px; border-radius: 3px 0 0 3px; }

    /* On hover, add a black background color with a little bit see-through */ .previus:hover, .next:hover { background-color: rgba(0,0,0,0.8); }

    /* The dots/bullets/indicators */ .bulletIndicators { cursor:pointer; height: 13px; width: 13px; background-color: #bbb; border-radius: 50%; display: inline-block; transition: background-color 0.6s ease;

    } /* :active MUST come after :hover (if present) in the CSS definition in order to be effective! */ .active, .bulletIndicators:hover { background-color: #717171; }

    /* Fading animation using webkit Webkit is a block element with a set of rule sets called Keyframes which can be used to style it in a given set time */ .fade { -webkit-animation-name: fade; -webkit-animation-duration: 1.5s; animation-name: fade; animation-duration: 1.5s; overflow:hidden;

    }

    @-webkit-keyframes fade { from {opacity: .4} to {opacity: 1} } /* fading alpha level- remember if the box display was set to none then the you should see the background colout briefly */ @keyframes fade { from {opacity: .4} to {opacity: 1} }

  3. Java-Script

    var slideIndex = 1; showSlides(slideIndex);

    function plusSlides(n) { showSlides(slideIndex += n); }

    function currentSlide(n) { showSlides(slideIndex = n); }

    function showSlides(n) { var i; var slides = document.getElementsByClassName("mySlides"); var dots = document.getElementsByClassName("bulletIndicators"); if (n > slides.length) {slideIndex = 1;} if (n < 1) {slideIndex = slides.length;} for (i = 0; i < slides.length; i++) { slides[i].style.display = "none"; } for (i = 0; i < dots.length; i++) { dots[i].className = dots[i].className.replace(" active", ""); } slides[slideIndex-1].style.display = "block"; dots[slideIndex-1].className += " active"; }

Answer №1

While exploring various techniques for moving boxes around in CSS, I stumbled upon the 'z-index' property. Experimenting with it, I decided to assign a high value to it - specifically setting z-index=30; within the header selector. It's worth noting that this may not universally apply to all elements, as their default z-indices are unknown to me.

header{
    background-color: white;
    color: white;
    position:fixed;
    top:0;
    border-bottom:1px solid #1e204c;
    display: block;
    width:100%; 
    z-index=30;
}

Answer №2

For stacking elements in front of others, consider utilizing the z-index property with a higher number on the desired object. ex

header{
  z-index: 99;
}

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

execute a rigorous compilation during the ng build angular process

I am currently working on a project using angular-cli and I have configured my package.json with the following scripts: "scripts": { "ng": "ng", "build": "ng build --base-href /test/", "prod": "ng build --prod --base-href /test/" } According to the ...

What is the best way to dynamically change the color of my component depending on the prop passed to it?

I am facing an issue with the color of my component changing based on the value of the prop 'level'. Despite using states to set the backgroundColor, all components end up having the same color due to the state being altered for every comment. I ...

Configuring content type for JavaScript files in Express for performance boost

Utilizing express to deliver a page with js files utilizing es6 modules. Learn more about es6 modules - https://jakearchibald.com/2017/es-modules-in-browsers/ The contents of my server.js file are: const app = express(); app.use( express.static( __dirn ...

Having trouble getting an HTML form to function with Ajax and PHP?

Seeking assistance from anyone who can lend a hand. I am delving into the complexities of Ajax, and I'm encountering issues where it seems like the script is being completely ignored or perhaps I'm just making a rookie mistake. Prior to display ...

Submitting information via jQuery

https://i.stack.imgur.com/VU5LT.jpg Currently, I am working on integrating an event planner into my HTML form. However, I am facing difficulty in transferring the data ("meetup", "startEvent", "break") from HTML to my database. Using jQuery, I was able to ...

Dynamically generate a new array every time a numeral is encountered within the Input Array in JavaScript

I'm facing a dilemma. I have an array with user input that contains both numbers and strings, like this:- 3 apple Lemmon sugar 2 Ginger Ice This is the data I'm working with. My task is to manipulate the data so that "Whenever it encounters a n ...

"Organizing Your Content: A Guide to Grouping Information under Specific

How can I organize content under different headings? I am using two methods to retrieve data: 1. axios.get('/api/get/headers') 2. axios.get('api/get/contents') I am struggling with how to properly structure this, especially since the ...

jquery disable document manipulation function

I need to make some updates to a simple function that involves the current textarea. $(document).on("keydown", updated_textarea_var, function (e) { // do stuff }); To achieve this, I tried disabling the previous function and running a new one w ...

Ways to conceal the player controls with mediaelementjs.com

Is there a way to display the control bar only when the user hovers over the video while using the mediaelementjs.com player? I feel like there might already be a function for this, but I can't seem to find it anywhere. Should I just implement a simpl ...

step by step guide on swapping a portion of a JSON string

I need to eliminate the character "C" from keys that start with C_ in the following JSON string. Here is the JavaScript object I have: var jsonData= { key1:val1, key2:val2, C_100:1, C_101:2, C_102:3, } The desired output should look like this: v ...

The ngOnChanges method fails to exhibit the anticipated modifications in a variable

Trying to grasp the concept of the ngOnChanges() callback, I created an example below. Despite having values for the attributes title and content in the Post interface during compile time, I do not see any logs from ngOnChanges. Please advise on the corre ...

Feature resembling a horizontal bar or progress bar within a table

I'm looking for ideas on how to display a horizontal bar chart or progress bar within a specific cell in a table (like Row 0, Column 2). For example, I want the text 8,088,874 to have a background color that visually represents the percentage. Curre ...

Differences in rendering of HTML select element between Chrome on macOS and Chrome on Windows

During testing of a section of the app at my workplace, it was discovered that dropdowns and select elements in a specific UI scenario appeared differently on Chrome for Windows and Ubuntu compared to Chrome for macOS. I attempted to analyze the elements ...

Tips for aligning text vertically within a definition list

I am working on a definition list where I need to vertically center the text within each dd element. dl, dt, dd { margin:0; } dt { background: blue; } dd { min-height: 100px; background: gold; border-bottom: 3px solid white; } <dl ...

Encountering issues with extension CLI - "Unable to utilize the import statement outside a module"

Recently, I've been attempting to integrate the Afinn-165 node package (https://www.npmjs.com/package/afinn-165) into my Google Chrome extension. The goal is to analyze the sentiment of text scraped from each page. Being a novice in web development, I ...

`The functionality of parent.location is not operating as expected in Firefox and Chrome, however, it is functioning

Issue with JSP: <A NAME="CustomerInformation"></A> <table class="SectionHeader1"> <TBODY>enter code here <tr> <td>Customer Information</td> </tr> </TBODY> </table ...

Angular 4 - The Promising Outcome: How to Retrieve the Value upon Completion

Is there a way to retrieve a value from a promise and store it in a global variable? I've been attempting to accomplish this, but the global variable remains undefined. import { Injectable } from '@angular/core'; import {ActivatedRouteSnap ...

jQuery uploads elements only when the page is initially loaded for the first time

The issue seems to be related to the $(document).ready(function() {}); code block or potential misuse of callbacks. My goal is to execute getTotalMarketCap(), getAllOtherValues(), and getMarketShare() in sequence for an accurate market share calculation. ...

Creating a connection between a class Bill and a class SimplifiedBill: Best practices

As stated in the title, I am faced with a situation where I have two classes: SimplifiedBill, which includes only date and finalPayment, and Bill, which has the same properties as SimplifiedBill but also additional details such as taxes, user data, and ser ...

How can I retrieve data using the angular method instead of the traditional $.ajax approach? Is $http a suitable replacement for $.ajax in Angular?

Here is the code snippet I have written. .state("dynamic", { url: "/:name", controller : 'AppHomeCtrl', templateUrl: function (params){ var myURL = params.name + '.html'; var validPage ...