Progress Bar Has Wandered Off Track

Having trouble with two queries. Take a look at the live view here

First Query: Struggling to position the progress bar below my image using CSS.

Second Query: Want to make the images slide left instead of fading with the progress bar in my Javascript.

code for first query

.slideshow {
  position:relative;
}

.slideshow-inner {
  position:relative;
}

.slideshow-inner img {
  position:absolute;
}

.progress-bar {
  background-image: -webkit-linear-gradient(#383838 0%, #505050 100%);
  background-image: -moz-linear-gradient(#383838 0%, #505050 100%);
  background-image: -o-linear-gradient(#383838 0%, #505050 100%);
  background-image: linear-gradient(#383838 0%, #505050 100%); 
  margin: 0;
  padding: 0;
  height: 20px;
  position:relative;
  width: 0%;
}

Code For Second Query

<script type="text/javascript">
  var currentIndex = 0;
  function progress() {
    $(".slideshow img").hide();
    $(".slideshow img").eq(currentIndex).show();
    $(".progress-bar").css("width", "0");

    currentIndex++;
    if (currentIndex > 2) {
    currentIndex = 0;
    }

    $('.slideshow-bar').animate({
      width: '100%'
    }, 5000, "linear", progress);
  }
  progress();
</script>

Code HTML

<div class="page-wrapper">
  <div class="slideshow">
    <div class="slideshow-inner">
      <img data-src="holder.js/100%x280/grey" >
    </div>
    <div class="slideshow-inner">
      <img data-src="holder.js/100%x280/sky">
    </div>
    <div class="slideshow-inner">
      <img data-src="holder.js/100%x280/vine">
    </div>
    <div class="slideshow-inner">
      <img data-src="holder.js/100%x280/lava">
    </div>
    <div class="progress-bar"></div>
  </div>
</div>

Answer №1

Issue number one: The use of position:absolute for the images is causing them to be removed from the normal flow of the document, resulting in the progress bar being positioned at the top since the images are no longer there to push it down. To resolve this, consider changing position:absolute to position:relative, or remove position entirely.

Second issue: It is necessary to restructure your HTML by creating a "container" that is wider than the actual display area. Use overflow:hidden on the display area to clip it, and then animate the newly created "viewport."

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 Perl script to identify and highlight rows based on specific cell values

I am struggling with how to highlight a row when Column F displays a value of F. I understand that I can achieve this using CSS/JS, but I keep hitting a roadblock. Coding is new to me, so I would greatly appreciate some assistance if possible. Objective: ...

Strange Interaction with Nested Divs in CSS Layouts

I am working on a webpage layout and currently it looks like this: https://i.sstatic.net/s4TOb.jpg I am trying to align the purple box inline with the pink box inside the yellow box, which is inside the green box. However, when I change the display proper ...

Issue: Assertion violation: The use of <Link> element is restricted to within a <Router>. Any solutions or suggestions?

In my React and Next Js application, I am utilizing react-router-dom for routing purposes. The dependencies listed in the package.json file are as follows: This is how my current package.json file looks: { "name": "MUSIC", "versio ...

Modify the class of rows in table 2 once a particular value of a radio button in table 1 has been selected

One issue I am facing is related to two tables with radio buttons. Each table highlights the corresponding row when a radio button is checked, working independently. However, I need a specific value from table 1 to un-highlight any previously checked rows ...

Challenges with looping in Jquery animations

I've been working on an animation function that I want to run in a loop. So far, I've managed to get it to work for one iteration, but I'm struggling to figure out how to repeat the loop a specific number of times. Below is the code for my a ...

Creating an HTML table from JSON data using JavaScript

I recently wrote some code that reads the contents of an XML file and converts it into JSON. The JSON data is then displayed in an HTML table. Everything seems to be working fine, but there's one issue - the first row of the table always shows as "und ...

Instructions for removing a single key value pair from every object in an array and transferring it to a designated object within the same array

I need to update an array of objects by adding a key and value (e.g., age:15) to an object with the name email, while removing the age property from other objects in the array. [ { name: 'test', lname: 'last', age: 5 }, ...

jQuery is not active on responsive designs

I have implemented a script in my JavaScript code that changes the color of the navigation bar when scrolling. The navigation bar transitions to a white color as you scroll down. However, I am facing an issue with responsiveness and would like to deactivat ...

Utilize JavaScript to assign a value to a concealed Pardot field

Recently, I've been working on setting a hidden Pardot field within an iframe. Oddly enough, when I manually input the query selector in my Chrome console, I successfully locate the element. However, when running this code snippet (embedded in the &l ...

What steps can I take to verify that all textboxes are filled and checkboxes are selected before allowing the user to submit the form?

Here is the JavaScript code and a snippet of the HTML that I am using to create a form. I am having trouble figuring out why the form can still be submitted even when there are empty fields. Ideally, a dialog box should pop up indicating which fields nee ...

Take action upon window.open

I have a code snippet here that opens a window. Is it possible to make an ajax call when this window is opened? window.open("http://www.google.com"); For instance, can I trigger the following ajax call once the window is open: var signalz = '1&apos ...

Can you identify the issue with the phase control in my sine wave program?

I have recently developed an interactive sine wave drawing web application. Below is the code snippet for reference: const canvas = document.getElementById("canvas"), amplitude_slider = document.getElementById("amplitude_control"), wavelength_slider ...

Experiencing a console error which reads: "SyntaxError: Missing ) after argument list."

While working on configuring a new React CSR app and incorporating some boilerplate libraries, I encountered an error in the console: Uncaught SyntaxError: missing ) after argument list (at @emotion_react_macro.js?v=30f6ea37:29894:134) I am hesitant to ma ...

Go to a distant web page, complete the form, and send it in

As the creator of Gearsbook.net, a social network for Gears of War players, I am constantly striving to improve the site's functionality. Currently, it is quite basic and in need of updates. One highly requested feature by users is the ability to lin ...

Angular2 (RC5) global variables across the application

I am seeking a solution to create a global variable that can be accessed across different Angular2 components and modules. I initially considered utilizing dependency injection in my `app.module` by setting a class with a property, but with the recent angu ...

What is the best way to create a jQuery object that encapsulates a snapshot of a DOM element?

Recently, I discovered that a JQuery object retains a reference to a DOM object. As the HTML is modified, the context of the JQuery object also changes. However, my concern now is how to log these changes without altering the history records of the JQuer ...

Is there a way to extract values from a particular object?

Currently, I am utilizing a JSON server to establish a straightforward login system. The data stored on the server is structured as follows: { "users": [ { "name": "user1", "password": "pass1", "email": "<a href="/cdn-cgi/l/emai ...

The function HandleKeyPress is failing to recognize the input from the down arrow

I'm currently working on developing a customized and user-friendly select input using React.js. My goal is to have the functionality where the up and down arrow keys behave like the tab key within the context of selecting options. In order to achieve ...

Scaling images using jQuery for enhanced visual appeal

I implemented a jQuery hover effect on my image gallery where the images have a default size of 265 x 172 and are displayed horizontally. My goal is to have the images swap out for larger ones sized at 449 x 223 when a user hovers over them. However, I wan ...

Achieving a 100% height sidebar that remains visible on the screen at all times in Bootstrap

Looking to achieve this specific layout: I want the left col-md-3 to maintain a consistent 100% height and always be visible on the screen - it's going to be a menu. The right side should function normally with scrolling capabilities. Appreciate any ...