Shift the items in the unordered list to the left

I am currently working on a carousel design. I have already finished coding the HTML and CSS, but I am unsure of how to shift the elements one by one to the right or left while ensuring that 7 pictures are always visible in the viewport.

.seccion {
    max-height: 700px;
    min-height: 700px;
}
div.animacionCel {
    height: 60%;
    min-height: 60%;
    max-height: 60%;
    overflow: hidden;
    margin: 0px;
    padding: 0px;
}
div.viewport {
    width: 100%;
    overflow: hidden;
    height: 100%;
}
ul.slides {
    list-style-type: none;
    padding: 0px;
    margin: 0px;
    width: 100%;
    height: 100%;
    display: inline-table;

    -moz-transition: all 1s;
    -webkit-transition: all 1s;
    -ms-transition: all 1s;
    -o-transition: all 1s;
    transition: all 1s;
}
ul.slides > li {
    display: inline;
    padding: 0px;
    margin: 0px;
    height: 100%;

    -moz-transition: all 1s;
    -webkit-transition: all 1s;
    -ms-transition: all 1s;
    -o-transition: all 1s;
    transition: all 1s;
}
ul.slides > li > img {
    padding: 0px;
    margin: 0px;
    height: 90%;
    width: 14.28%;
}
ul.slides > li.activo > img {
    padding: 0px;
    margin: 0px;
    height: 100%;
    width: 14.28%;
}
<html>
    <head> </head>
    <body>
        <!-- second section -->
        <section class="seccion center-block">
            <div class="animacionCel center-block">
                <div class="viewport">
                    <ul class="slides">
                        <li><img src="../images/screen_cel_1.png"/></li>
                        <li><img src="../images/screen_cel_2.png"/></li>
                        <li><img src="../images/screen_cel_3.png"/></li>
                        <li class="activo"><img src="../images/screen_cel_4.png"/></li>
                        <li><img src="../images/screen_cel_5.png"/></li>
                        <li><img src="../images/screen_cel_6.png"/></li>
                        <li><img src="../images/screen_cel_7.png"/></li>
                        <li><img src="../images/screen_cel_8.png"/></li>
                        <li><img src="../images/screen_cel_9.png"/></li>
                        <li><img src="../images/screen_cel_10.png"/></li>
                        <li><img src="../images/screen_cel_11.png"/></li>
                        <li><img src="../images/screen_cel_12.png"/></li>
                        <li><img src="../images/screen_cel_13.png"/></li>
                        <li><img src="../images/screen_cel_14.jpg"/></li>
                        <li><img src="../images/screen_cel_15.png"/></li>
                        <li><img src="../images/screen_cel_16.jpg"/></li>
                        <li><img src="../images/screen_cel_17.jpg"/></li>
                    </ul>
                </div>
            </div>
        </section>
    </body>
</html>

Using JQuery animate has been my attempt so far.

Answer №1

Check out this JSFiddle demonstration:

http://jsfiddle.net/gxlmfp9s/1/

Using Vanilla JavaScript

setInterval(rotateImages, 1000); // Every 1 second

function rotateImages() {
    const firstLI = document.querySelector('ul.images li');
    document.querySelector('ul.images li.active').classList.remove('active'); 
    const centerLI = document.querySelectorAll('ul.images li')[4]; 
    centerLI.classList.add('active'); 
    document.querySelector('ul.images').appendChild(firstLI); 
}

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

Vue Component Update DisorderI hope this meets your expectations

Below is my code using Bootstrap, Vue, and Axios: SETUP: *Please disregard the tab-contents in component_a main.js Vue.component('component_a', { props: ['info'], template: `<div> // Component A template code here } ...

Exploring the power of NodeJS 8.x with EventEmitter and the efficiency of async/

Is it possible to use async functions with an event emitter? Some sources advise against it, but I am interested in incorporating async functionality with the event emitter to handle messages. Below is the code snippet I have been working on: server.on(& ...

How can I incorporate the URL bar with jQTouch?

Currently working on a mobile website using jQTouch. For instance, if we take the official demo site as an example and visit this link, we will land on the main screen. Navigating to AJAX -> Get Example, we notice the location bar changing to /#get. Ho ...

Placing a forward slash only after the initial hyperlink within a list item

I'm trying to add a slash after the first link in my UL, but instead, it's adding a slash after every link. I've attempted various solutions without success. Here is my current view/html code: <?php foreach ($this->config->i ...

The issue persists as AJAX data and text box data are not being saved simultaneously

I need assistance with an Ajax setup. I am trying to pass the screenwidth information along with a user input value from a text box to a PHP page. However, I am encountering issues as the only value being passed is from the textbox and the other one is sho ...

Updating CSS property names with jQuery: A step-by-step guide

My issue involves a div with inline style "left: Random Number". I have attempted to use various CSS change functions, but none have been successful. The problem lies in the fact that the property of left is random, and I am trying to change it to right. ...

JavaScript ACTING UP -> CROSS-ORIGIN RESOURCE ACCESS ERROR

After extensive research and troubleshooting, it dawned on me that the issue was not with JavaScript itself. Instead, I was facing a cross origin resource exception, which occurred because the ajax request was unable to access my server script due to lac ...

Guide to creating a Chrome extension that can detect updates in MongoDB documents

I have developed a chrome extension for syncing links, which stores the data in a MongoDB database using a custom REST API. While I am successfully able to push changes to the database and listen to them using a change stream in the REST API, I am facing d ...

Angular 4: Modifying the URL without the Component being Displayed

I'm currently facing an issue where I am attempting to link a component from one component using routerLink = "selected" const routes: Routes = [ { path: '', children: [ { path: 'account&apo ...

Problem with Angular controller

Recently delving into the world of angular.js, I encountered an issue while trying to run a basic controller example. The error message reads: [ng:areq] http://errors.angularjs.org/1.4.7/ng/areq?p0=Mycontroller&p1=not%20a%20function%2C%20got%20undefin ...

How to detect and handle errors in a jQuery ajax error callback?

In my applications, I frequently use jQuery ajax calls to communicate with the server side. Typically, when an error occurs on the server side, I serialize an errorMessage and send it as a response in JSON format. For example: { "ErrorMessage" : "Someth ...

How can you utilize Fetch to retrieve data from a Backend API?

One challenge I am facing is how to correctly access my Backend API in Ruby to fetch translated text from a translation service. Specifically, I am unsure about the correct endpoint to use when making the backend API call. Messages.vue methods { loadT ...

Use the .html() function to alter the content of several sets of radio buttons simultaneously by changing

Here are the different options for a product. I need help with the .change() syntax to update pricing based on the following calculations: Bundle One + Marble Color = 15$ Bundle One + Black Color = 18$ Bundle Two [Most Popular] + Marble color = 25 ...

Positioning buttons in a grid using CSS - Tips and tricks

Help needed! Seeking professional advice. I have a few issues that I can't seem to solve on my own. Firstly, regarding the second menu - should I use padding to position it correctly? Secondly, although I managed to make the navigation bar visually s ...

Tips and Tricks for Managing an Extensive Array of AJAX Requests (Exceeding 1000)

My application is retrieving a User's Google Contacts from the Google Contacts API on the front end, resulting in a variable number of JSON objects, usually ranging between 1 to 2000. Upon receiving these objects, the app goes through each one, reform ...

Is it possible to encounter the issue of "Context Lost" and "Importing multiple instances" in Three.js?

I am in the process of developing a 3D editor that allows users to manipulate a 3D scene and then view the result by pressing a "play" button. In order to display the output, I am utilizing an iframe. Below is the snippet of my HTML code: <iframe id=&qu ...

Extract PHP variable and incorporate it into JavaScript code

After doing some research online, I was unable to find a solution to my issue. Can anyone provide assistance with this problem? I currently have a javascript variable that contains the name of a PHP session address. I am trying to access this session valu ...

Tips for setting up a blog using nodejs and express.js

Hello everyone, I could really use some assistance. I am trying to figure out how to set up a blog using NodeJS specifically with ExpressJS, including basic functions like deleting, adding, and removing posts and comments, as well as standard authenticati ...

How can I ascertain which ajax request is on the verge of being executed?

In my current project, I have implemented multiple ajax calls that execute periodically using the timeInterval() method. To indicate loading or refreshing effects, I'm utilizing the following code snippet: jQuery(document).ajaxStart(function(){ ...

What is the most effective method in React JS to achieve real-time results with every keystroke by making REST calls to the server?

We are dealing with a huge database and the task at hand is to display results as the user types them in the search box. Preloading queries to attempt matching is out of question due to the enormity of our data. Currently, we make a server request with th ...