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

Vue's Global mixins causing repetitive fires

In an effort to modify page titles, I have developed a mixin using document.title and global mixins. The contents of my mixin file (title.ts) are as follows: import { Vue, Component } from 'vue-property-decorator' function getTitle(vm: any): s ...

Can the start and stop times of the typed.js plugin be controlled for typing text?

The typed.js jQuery plugin creates the illusion of text being automatically typed on screen by a robot. Despite researching the resources related to this plugin, I have not come across any information on how to control the starting and stopping of the typi ...

Customizing the appearance of the Bootstrap Typeahead

I've been experimenting with the Bootstrap Typeahead for my search feature. I successfully implemented the dropdown list using Ajax. However, I am looking to customize the width, padding, and background color of the dropdown menu, which is currently w ...

Optimal Strategies for Handling Slugs with Laravel and Vue Router

I am working on a Laravel and Vue application. Specifically, I have developed a single-page application using Vue for a section called "shop". Within this shop, there are 3 subpages: "about", "products", and "contact". In my routes.php file: Route::get(& ...

Instructions for correctly integrating the ng2-datepicker module into an Angular 2 application

Ng2-datepicker (1.0.6) Angular2 (2.0.0-rc.5) As I attempted to implement it in my HTML following the documentation, I encountered the following error: zone.js:484 Unhandled Promise rejection: Template parse errors: Can't bind to 'ngMode ...

Using Node JS, how to pass a variable length array to a function?

Is there a way to dynamically call an addon function with varying argument lengths? I capture user input in a variable like this: Uinput = [5,3,2]; Now, I want to pass these numbers as arguments to my addon function like this: addon.myaddon(5,3,2); I n ...

Transform current JSON data into formatted JSON format using JavaScript or TypeScript

I have a JSON structure that needs to be reformatted in order to meet the requirements of an external service. Although the current format is complex and cannot be altered, I need to modify it to match the desired output for the external service. Current ...

The error message "404 Not found" is returned when attempting to retrieve a Google spreadsheet

I have exhausted all of my options on the web trying to retrieve my Google spreadsheet as a json file. $.getJSON() However, I am constantly receiving a 404 Not Found error. When I publish to the web, the URL I get is: https://docs.google.com/spreadsheets ...

Could you assist me in navigating the process of creating a dynamic 10x10 multiplication table using HTML and JavaScript? I'm eager to learn where to begin with this methodology

As I explore various questions related to the "simple" multiplication tables, I find myself with a more fundamental query. I am seeking clarity on how Javascript operates when intertwined with HTML, as that is where my confusion lies. In my multiplication ...

issue with vue watch not updating mapState

I have a component where I am using a store value and attempting to update it. The issue I am facing is that even though the store value changes when I click the button, this change is not being reflected in the component output (i.e. {{query}}). < ...

Error: Unexpected token : encountered in jQuery ajax call

When creating a web page that requests remote data (json), using jQuery.ajax works well within the same domain. However, if the request is made from a different domain (e.g. localhost), browsers block it and display: No 'Access-Control-Allow-Or ...

An error has occurred in nodejs: headers cannot be set after they have already been sent

I'm a newcomer to Node.js and encountering some challenges. Whenever I attempt to open 127.0.0.1:3000/bejelentkezes, I encounter the following error: POST /bejelentkezes 500 550.784 ms - 2259 GET /css/404.css 304 2.751 ms - - 1 Successful login Erro ...

Encountered an issue while attempting to connect MongoDB to Node.js

``const timeoutError = new error_1.MongoServerSelectionError(Server selection timed out after ${serverSelectionTimeoutMS} ms, this.description); .MongoServerSelectionError: connect ECONNREFUSED ::1:27017 const {MongoClient}=require('mongodb'); c ...

Customizing your buttons in Wordpress with extra CSS styles upon clicking

I am in the process of developing a Wordpress website and I require a button for switching between mobile and desktop versions manually. Within my .css file, I have included: @media (pointer:coarse) {} This adds modifications for the mobile version ...

Having trouble accessing data from MongoDB using Node.js and Express

Looking to retrieve data from Mongo DB using Node JS and Express JS? After creating a mongoose schema and exporting the module, you may encounter an issue where running the function returns an empty JSON object. Take a look at the code snippets below: Thi ...

What is the best method for displaying plain text using the br tag?

My component looks like this: class News extends Component { state = { isSimple: this.props.isSimple } render() { return ( <div> <div className="extended">extended</div> simple text </div&g ...

Leveraging JSON for parsing xmlhttp.responseText to auto-fill input fields

Is there a way to utilize JSON for parsing xmlhttp.responseText in order to populate textboxes? I've been struggling to achieve this using .value and .innerHTML with the dot notation, along with b.first and b.second from the json_encode function in th ...

Is there a way to access an HTML element using Vue's methods?

Here is an example of my Vue component structure: <template> ... </template> <script> export default { methods: { buildDescription () { if (!this.description) { const div = document.createEl ...

Error: JavaScript function call did not provide a return value

Currently, I am in the process of creating a straightforward angular2/expressJS application. Within my expressJS code, I have an HTTP GET router call that retrieves all users from MongoDB and successfully returns them: app.get('/getusers', funct ...

Enhance your browsing experience by inputting valuable information into the

I am looking to enhance a text box by adding values. The text box already has a default value of 10, and I want to create a button that will add new text boxes with a limit of 4. My goal is to continuously add values from text box 1 to text box 4. For exa ...