Dynamic scrolling feature for lists that moves horizontally

When working with a lengthy list, I encountered an issue with horizontal scrolling. It worked fine when the list was statically implemented as shown below.

 <div style="margin-top:100px;white-space: nowrap;">
  <ul >
    <li style="display:inline">wfwe1</li>
    <li style="display:inline">wfwe2</li>
    <li style="display:inline">wfwe3</li>
    <li style="display:inline">wfwe4</li>
    <li style="display:inline">wfwe5</li>
    <li style="display:inline">wfwe6</li>
    <li style="display:inline">wfwe7</li>
     <li style="display:inline">wfwe1</li>
    <li style="display:inline">wfwe2</li>
    <li style="display:inline">wfwe3</li>
    <li style="display:inline">wfwe4</li>
    <li style="display:inline">wfwe5</li>
    <li style="display:inline">wfwe6</li>
    <li style="display:inline">wfwe7</li>
  </ul>
 </div>

However, when I tried to fetch the list via a loop, it did not display inline and therefore, horizontal scrolling was not possible. My attempted solution is outlined below.

 <div
  style="margin-top:100px;white-space: nowrap;">
  <ul
    v-for="(infoChildBtn, index) in infoSubContracts"
    :key="index"
    @click="infoTopBtnFun1(index, infoChildBtn)">
    <li style="display:inline">
      {{ infoChildBtn }}
    </li>
  </ul>
</div>

I am seeking guidance on where I went wrong and how to resolve this issue.

Answer №1

One key distinction between your static demonstration and the Vue implementation is that you are utilizing v-for on the ul element. Consequently, the outcome will resemble this:

<ul>
    <li style="display:inline">wfwe1</li>
  </ul>
  <ul>
    <li style="display:inline">wfwe2</li>
  </ul>
  <ul>
    <li style="display:inline">wfwe3</li>
  </ul>
  <ul>
    <li style="display:inline">wfwe4</li>
  </ul>

To remedy this issue, consider modifying your Vue template to:

<div style="margin-top:100px;white-space: nowrap;">
  <ul>
    <li
      style="display:inline"
      v-for="(infoChildBtn, index) in infoSubContracts"
      :key="index"
      @click="infoTopBtnFun1(index, infoChildBtn)">
      {{ infoChildBtn }}
    </li>
  </ul>
</div>

This way, you are looping through the li tag instead of the ul tag.

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

Convert a relative path to an absolute path using the file:// protocol

When I scrape a website with similar html content, I come across the following code: <a href="/pages/1></a> In addition to this, I have access to the window.location object which contains: origin:"http://www.example.org" This allows me to ...

I tried utilizing the wrapper feature, but unfortunately, the modal did

import React, { PropTypes } from 'react'; import Dialog from 'material-ui/Dialog'; export default class CustomModal extends React.Component { constructor(props){ super(props) } handlePrimaryButton = () => { this.prop ...

What is the best way to incorporate a text box along with a submit button that triggers a callback to a javascript function when clicked, utilizing either plain javascript or jQuery?

As a beginner in the world of JavaScript, I'm struggling to find the solution to this problem. Any assistance would be greatly welcomed. ...

Every individual child component must be assigned a distinct key prop, even if they are pre-defined. - Utilizing REACT

My navigation bar routes are sourced from a JSON file structured like this: { "categorias": [ { "nombre": "Teacher absences", "componentes": [ { "type": "url", ...

Looking for a way to retrieve JSON data from an HTML page using JavaScript? Look no further

There is a page that sends me JSON data. You can make the request using the GET method: or using the POST method: argument --> unique_id=56d7fa82eddce6.56824464 I am attempting to retrieve this information within my mobile application created with Inte ...

How can you deactivate all form elements in HTML except for the Submit button?

Is there a method available to automatically deactivate all form elements except the submit button as soon as the form loads? This would entail pre-loading data from the backend onto a JSP page while restricting user access for editing. Users will only be ...

Issue with margins of sections when attempting to activate menu class while scrolling

My Objective: I want to create a website where the menu highlights the section that is currently being viewed as the user scrolls up and down. Progress So Far: I have successfully implemented a functioning menu that changes to "active" when the correspo ...

Enhance accessibility: Improving screen reader and tab focus behavior with vue-router

It seems that focus resetting and screen readers detecting route changes are not integrated into vue-router. I understand why Vue might have omitted this feature, considering the varying use cases, but I am surprised by the lack of information on accessib ...

Enhancing MongoDB performance with Mongoose for efficient array save or update operations

After a user saves a question, the question may include a list of "tags". To handle this data efficiently, I need to compare these tags with existing ones in the collection. If a tag already exists, its count should be updated; otherwise, it needs to be ...

What are the steps for setting up API REST calls proxy for a frontend hosted on Netlify?

While testing locally, I am able to successfully post a call and access it through Netlify. However, once I host the frontend app on Netlify, the POST Proxy is being set to the Netlify URL. The hosted URL: Upon clicking "Sign Up" and then clicking on "Si ...

Master the art of utilizing angular-filter

Encountering some challenges while attempting to utilize angular-filter: The following links have been imported into the HTML file: <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js"></script> <script src=" ...

What is the most efficient way to transfer a large volume of documents from mongoDB using http?

I'm dealing with a large mongoDB database that contains millions of documents and I need to fetch them all at once without crashing or encountering cursor errors. My goal is to send this data over http using express in nodeJS. The collection contains ...

The position of the scroll bar remains consistent as you navigate between different websites

Is it possible for me to click on a link within my HTML website and have the other website load with me in the exact same position? For example, if I'm halfway down a webpage and click a link, can I be taken to that same point on the new page? If so, ...

Tips on obtaining standardized values for an array with ng-repeat

My goal is to retrieve the normalized value of an array associated with different groups without altering the original array items. Instead, I am creating new objects for each group's normalized items. http://jsfiddle.net/k5Dvj/5/ $scope.nomalizedIt ...

When a child component is updated, React does not automatically re-render

My goal is to pass the email from the SigninForm back to the App component and trigger a re-render when the email is updated. I attempted to follow the structure outlined in a previous question on Stack Overflow, but unfortunately, I couldn't get the ...

How to obtain the height of the parent screen using an iframe

Imagine a scenario where a div contains an image that is set to perfectly fit the height of the screen. This setup works flawlessly, with one exception - when placed within an iframe, the height of the div adjusts to match the content's height rather ...

How to properly implement ng-if for a select option in Angular.js?

Within the controller, I defined a scope variable: $scope.readOnly = true. In the HTML code: <select ng-if="readOnly" ng-model="readOnly" required> <option value="true" selected>True</option> <option value="false">False ...

Utilizing v-for with keep-alive in Vue3

Issue at Hand I have a varying number of Tab components; the count can range from 1 to 10, but only one is visible at any given moment. Nonetheless, I aim to retain them in memory during switches. My initial thought was to utilize a v-for loop within a &l ...

Tips for effectively testing an Angular directive

I'm having trouble testing an Angular directive due to encountering the following unexpected error: Error: Unexpected request: GET /api/players/info It seems that the issue may stem from references to my controller within the directive definition ob ...

Fetch the user's email address from Auth0 using an asynchronous function

I am trying to load the user's email from Auth0 and store it in a constant. However, I am getting an arrow. I cannot identify the error. Can anyone help me find a solution? const userEmailInfo = async () => { auth0Client = await auth.createClien ...