What's the best way to remove the left border from the initial visible child in a list?

I would like to create a design similar to this:

However, I am struggling with the following:

How can I remove the left border from the first visible child?

I have not been able to replicate the exact example, but you can check out my jsFiddle for an idea.

<body onload='getAllListItems()'>
    <div id='t'>

    <button id='left' onClick="move(left)">
        <</button>
            <div id='list'>
                <ul id='list-items'>
                <li class="list">slide1</li>
                <li class="list">slide2</li>
                <li class="list">slide3</li>
                <li class="list">slide4</li>
                <li class="list">slide5</li>
                <li class="list">slide6</li>
                <li class="list">slide7</li>
                <li class="list">slide8</li>
                <li class="list">slide9</li>
                <li class="list">slide10</li>
                <li class="list">slide11</li>
                </ul>
            </div>

        <button id='right' onClick='move(right)'>></button>
 </div>        
</body>

ul {
    float:left;
    height:50px;
    width: 800px;
    overflow: hidden;
}
#t{
    background-color:#f16f00;
    border: 1px #ffffff solid;
}
ul li {
    border-left: 1px solid;
            border-left-color: #f16f00;
            color: #ffffff;
            text-align: center;
            width: 100px;
            height: 50px;
            float: left;
            list-style-type: none;
            background-color:#032258;
            padding-top: 0;
            padding-bottom: 0;
}
ul li:first-child {
    display: block;
}
#left, #right {
    float:left;
    height:50px;
    background-color:aqua;
    font-size:2em;
    padding-left: 20px;
    padding-right:20px;
}



 var list_items = [];
    var index = 0;
    var list_length = 0;

    function getAllListItems() {
        var temp = document.getElementsByClassName('list');
        console.log(temp);
        for (i = 0; i < temp.length; i++) {
            list_items.push(temp[i]);
        }

        list_length = temp.length;
    }

    getAllListItems();

    function move(dir) {

        if (dir === left) {
            var k = index + 1;
            console.log('i:'+index);
            console.log('k:'+k);
            list_items[index].style.display = 'block';
            list_items[index].style.border = 'none';
            index--;

            list_items[k].style.borderleft = '1px solid #425982';

            if (index < 0) {
                index = 0;
            }
        } else if (dir === right) {

            list_items[index].style.display = 'none';





   if (index >= ((list_length) - 1)) {
            index = (list_length) - 1;
        } else {
            index++;
        }
    } else {
    }
}

Answer №1

ul li:first-child {
    display: block;
    border-left:0px solid red;
}

Incorporate the following code to your existing ul li:first-child class: border-left:0px solid red;.

Check out the DEMO here

We have made some adjustments to provide you with the solution you were seeking. Your initial question was a bit unclear.

 var list_items = [];
    var index = 0;
    var list_length = 0;

    function getAllListItems() {
        var temp = document.getElementsByClassName('list');
        console.log(temp);
        for (i = 0; i < temp.length; i++) {
            list_items.push(temp[i]);
        }

        list_length = temp.length;
    }

    getAllListItems();

    function move(dir) {

        if (dir === left) {
            var k = index + 1;
            console.log('i:'+index);
            console.log('k:'+k);
            list_items[index].style.display = 'block';
            list_items[index].style.borderLeft = 'none';
            index--;
            
            list_items[k].style.borderLeft = '1px solid #f16f00';

            if (index < 0) {
                index = 0;
            }
        } else if (dir === right) {

            list_items[index].style.display = 'none';
 list_items[index+1].style.borderLeft = '0px solid red';


            if (index >= ((list_length) - 1)) {
                index = (list_length) - 1;
            } else {
                index++;
            }
        } else {
        }
    }
ul {
    float:left;
    height:50px;
    width: 800px;
    overflow: hidden;
}

#t{
    background-color:#f16f00;
    border: 1px #ffffff solid;
}

ul li {
    border-left: 1px solid;
            border-left-color: #f16f00;
            color: #ffffff;
            text-align: center;
            width: 100px;
            height: 50px;
            float: left;
            list-style-type: none;
            background-color:#032258;
            padding-top: 0;
            padding-bottom: 0;
}

ul li:first-child {
    display: block;
    border-left:0px solid red;
}

#left, #right {
    float:left;
    height:50px;
    background-color:aqua;
    font-size:2em;
    padding-left: 20px;
    padding-right:20px;
}
<body onload='getAllListItems()'>
    <div id='t'>
    
    <button id='left' onClick="move(left)">
        <</button>
            <div id='list'>
                <ul id='list-items'>
                <li class="list">slide1</li>
                <li class="list">slide2</li>
                <li class="list">slide3</li>
                <li class="list">slide4</li>
                <li class="list">slide5</li>
                <li class="list">slide6</li>
                <li class="list">slide7</li>
                <li class="list">slide8</li>
                <li class="list">slide9</li>
                <li class="list">slide10</li>
                <li class="list">slide11</li>
                </ul>
            </div>

        <button id='right' onClick='move(right)'>></button>
 </div>        
</body>

View the Updated Fiddle here

Modifications in the CSS

ul li:first-child {
    display: block;
    border-left:0px solid red;
}

Revisions in the JavaScript section

    function move(dir) {

    if (dir === left) {
        var k = index + 1;
        console.log('i:'+index);
        console.log('k:'+k);
        list_items[index].style.display = 'block';
        list_items[index].style.borderLeft = 'none';
        index--;

        list_items[k].style.borderLeft = '1px solid #f16f00';

        if (index < 0) {
            index = 0;
        }
    } else if (dir === right) {

        list_items[index].style.display = 'none';
         list_items[index+1].style.borderLeft = '0px solid red';


        if (index >= ((list_length) - 1)) {
            index = (list_length) - 1;
        } else {
            index++;
        }
    } else {
    }
}

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

Guide to setting up Firebase pagination in a NextJS 13 server component

Currently, I am working on developing a product page that showcases all products and functions as a server component. The challenge I am facing is the inability to pass the last visible document snapshot required by the startAfter() query. Below is the fu ...

Tips for dynamically adjusting the height of the select2 input box (multiple)

In my project, I have implemented a select2 input box for multiple selections. The user can choose as many options as they want, but if the selected options take up more space than the available width, I need the select box to automatically increase in hei ...

I've managed to mess up my code again; local storage was working fine, and now it's not. I'm completely clueless

I attempted to store the best game times in local storage by creating an empty array called gBestScores. I compared the value of the last best score to the current one and decided whether to push it into the array or not. However, despite my efforts, the ...

The browser is lagging behind a few frames when repainting on high-resolution displays

Currently, I'm working on a website that features an infinite grid. Users have the ability to navigate through the grid by simply holding down the right click on their mouse and moving it around. The technical details: To achieve this functionality, ...

Crawlers designed to handle websites with never-ending scroll feature

Currently seeking a crawler application that can analyze the JavaScript on a webpage for AJAX requests and identify functions that initiate those calls in order to retrieve all content from start to finish. I would develop this myself, but my workload is ...

There was a problem with the WebSocket handshake: the response header value for 'Sec-WebSocket-Protocol' did not match any of the values sent

I've encountered an issue with my React project that involves streaming live video through a WebSocket. Whenever the camera firmware is updated, I face an error in establishing the WebSocket connection. Here's how I initiate the WebSocket: wsRe ...

Is there a way to eliminate a specific input box using the jquery remove function?

I've been working on some code and have run into an issue. Currently, the remove function only works on one input box that is created with the append function. I would like it to be able to work on every input box generated through the append function ...

Managing Angular signals: updating an element in an array that belongs to an object

Could it be that I am overcomplicating things by using complex signals? Please advise if what I am attempting to achieve is not a suitable use-case for Angular's Signals. However, I strongly believe that it should be achievable! I have a service in p ...

Reactjs: When components are reused, conflicts may arise in UI changes

I'm currently working on creating a sample chat room application using reactjs and redux for educational purposes. In this scenario, there will be 3 users and the Message_01 component will be reused 3 times. Below is the code snippet: const Main = Re ...

Best practice for including the language tag in Next.js Head tag

I'm struggling to find a clear example of how to use the language tag with Next Head. Here are two examples I have come across. Can you help me determine which one is correct, or if neither are appropriate? Just a reminder: it doesn't need to be ...

Is the security of Angular's REST authentication reliable?

My goal is to establish a secure connection with a REST service using Angular. I have come across the official method, which involves setting the authentication ticket like this: $httpProvider.defaults.headers.common['Authorization'] = 'dhf ...

Transform your HTML elements selected with jQuery into interactive spinners

In my current setup, I have a Select element that is populated dynamically. To illustrate with some static values, it would resemble the following: <form method="get" action=colours.php"> <select name="id"> <option value="1">Red< ...

Supply mandatory argument along with varying arguments to the function

I have a function that requires one parameter and a dynamic set of additional parameters. I am passing an array of blobs to the function. Below is a simplified version of the function: function test(directory, blob0, blob1) { for (var argumentIndex = 1; ...

Connecting an established React library

Struggling to integrate my existing project with this react.js library from resin-io-modules https://github.com/resin-io-modules/rendition I managed to install and run the storybook example, but I'm facing issues referencing it in my own App.js file ...

What is the best approach for adding a mark within a circle using React or vanilla JavaScript?

Has anyone come across an npm package that allows for marking a dot in a circle? I am looking to click on the mark and output the JSON object. https://i.sstatic.net/u8FTY.png Additionally, is there any option to achieve this with a simple onClick event? ...

Utilize data obtained from an ajax request located in a separate file, then apply it within a local function

Seeking assistance in navigating me towards the right path or identifying my errors. Pardon if my explanation is unclear, please be gentle! Currently, I am engaged in developing a function that executes an ajax call with a dynamically generated URL. The o ...

Unable to view React Component

I am experiencing an issue where Foo is being displayed but not Bar in my project. I have been following a tutorial and using a different API, but the code structure remains the same. Despite this consistency, I can't seem to figure out why Bar is not ...

``Can the content visible to an iframe be controlled by manipulating window.top?

There's a unique web application that functions by loading various iframes into itself. It offers some code that the child iframes can connect with. The child iframes use window.top, which is beyond my control but everything runs smoothly. Now, I ai ...

Stacking two divs for the team section layout

Although I'm new to this, I've been struggling to achieve a specific layout for a team page. My goal is to display a picture on the left side and text on the right for each team member. The design includes the person's name, title, and a set ...

Is there a way for me to retrieve the value nested within an object within another object from this Api response?

Hey there, I'm currently struggling to retrieve the value of faceit_elo from within the csgo object. I attempted using data.games.csgo.faceit_elo but unfortunately it didn't yield any results. Any suggestions on how to access this value would be ...