Despite utilizing overflow and wrap properties, HTML lists still fail to display horizontally

Make sure to copy the code and run the HTML file first. For organization, place the JavaScript file in the scripts folder and the CSS file in the styles folder.

The issue at hand is that the li elements are not displaying horizontally as intended; they need to be wrapped properly.

Upon adding student information in the HTML page without refreshing, each new detail appears on the page. The problem arises with the two checkboxes that determine the type of view. The desired outcome is for these elements to appear horizontally. Instead of wrapping onto a new line once it crosses the region of the ul element, there should be a horizontal scroll feature.

var name;
var age;
var dob;
var id;
var street;
var city;
var id1;
// Declarations for variables

function ver() {
  console.log("Vertical view");
  $("#displayDetails").removeClass("hor").addClass("ver");
}

function hor() {
  console.log("Horizontal View");
  $("#displayDetails").removeClass("ver").addClass("hor");
}
   
$(window).load(function() {
  // Triggered when the entire page, including frames, objects, and images, is fully loaded
  console.log("Window has finished loading");
});

$(document).ready(function() {
  // Executes when the HTML document is loaded and the DOM is prepared
  console.log("Inside document.ready(function())");

  $("button").click(function() {
    // Event listener for button click

    ...

      

// More code goes here
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<html>

....

// Remaining HTML and script codes go here

Answer №1

To achieve a horizontal layout, you can use the following CSS code:

ul#displayDetails{
  list-style-type: none;
  display: inline-flex;
  overflow-x: auto;
  background-color: #999999;
  max-width: 300px;
}

ul#displayDetails li{
  padding-right:40px;
  min-width: 100px;
}

Remember to remove the background-color:#999999; from the parent div of the ul.

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

Understanding the process of extracting HTML tags from an RSS feed using Python

I am looking for a way to create a plain text readout of an RSS feed using a small utility. Below is the code I have: #!/usr/bin/python # /usr/lib/xscreensaver/phosphor -scale 3 -program 'python newsfeed.py | tee /dev/stderr | festival --tts' ...

Tips for retrieving response from AJAX data array in Highcharts

I'm facing an issue while trying to retrieve JSON data using AJAX. I keep encountering the following error message: Uncaught TypeError: Cannot read property '0' of undefined. Below is an example of my simple chart data: <script type="te ...

Creating a scrolling sidebar in Bootstrap 4

Today I learned about CSS Bootstrap 4 and created my template with a sidebar. However, when there are many menus, I want the sidebar to show a scrollbar. I am looking for help on how to make a scrollbar appear on my sidebar template. Below are my HTML and ...

Creating an array of objects data is a breeze with Vue.js

I have an array of data containing selected items, and I need to extract the IDs from this array into a new array so that I can send only the IDs to the back-end. Sample Code method toggleSelection(rows) { console.log('this.multipleSelection : &a ...

The pqselect plugin in jquery is malfunctioning without any visible errors

I'm really struggling to get this plugin to work. It's the jQuery pqselect plugin for creating multiple select boxes with checkboxes. Even though I've followed the usage instructions, it still doesn't seem to be functioning correctly. ...

Enhancing User Experience: Creating a Vue Button Component for Adding Items to Cart with the Power of Axios and Laravel Backend Integration

I have recently developed a Vue3 shopping cart with an "Add One" button feature. When the user clicks this button, it updates an input field of type "number" and sends a request to update the database using Axios along with Laravel's createOrUpdate me ...

Implement horizontal scrolling feature to code container

One cool feature on my blog is the codebox where I can insert snippets of HTML, CSS, and Javascript codes. Here's an example of how my CSS code looks: .post blockquote { background-image: url("https://dl.dropbox.com/u/76401970/All%20Blogger%20Tr ...

Establishing a primary data format for a backbone collection

Is there a way to configure a Backbone collection to always include a content type of "application/json" in every request it makes? I have tried the following code snippets: myCollection = Backbone.Collection.extend({ headers: {"Content-Type": 'ap ...

Error message: "Unable to access 'title' property of an undefined value" for an item with a length of 1

Despite the fact that the collection is not undefined and the `title` attribute is also not undefined, for some reason I am unable to read the `title` attribute from the `received` variable. The error indicates that it is undefined. var received = document ...

The complexity of JQuery's design has left many puzzled

I am new to using Jquery and I have come to the following realizations: Every selector in Jquery always returns a wrapped list of items, which can be: An empty list A list with a single element A list with multiple elements Chained functions operate o ...

Exploring the capabilities of mongojs: Adding items to arrays within fields

I've been researching extensively on this subject, but I'm completely stumped. Here's my dilemma (I'm working with node.js and mongojs): I want to create documents like the following: { "_id" : ObjectId("50ce2f7f98fa09b20d000001" ...

Is Firefox the only browser where the webpage is displayed off-center?

I've encountered a strange issue with my website that I can't seem to figure out. Despite searching extensively on Google and Stackoverflow, I haven't come across anyone else facing the same problem. During testing in different browsers lik ...

Is there a way to differentiate between a browser application running on a local development server and an online staging server?

Is there a way to conditionally call a component only on the staging server and not on the local machine in Vue.js? <save-drafts-timer v-if="!environment === 'development'" /> ... data () { return { environment ...

What is the best way to store a JavaScript variable in a SESSION for seamless pagination implementation?

I'm working on a website where I need to adjust the number of visible items on the screen based on the screen size. Specifically, I have a gallery that should only display as many images as can fit on the screen at once. To achieve this, I've al ...

A step-by-step guide on enhancing error message handling for Reactive forms in Angular

Here is a code snippet that I'm working on: public errorMessages; ngOnInit(): void { this.startErrorMessage(); } private startErrorMessage() { this.errorMessages = maxLength: this.translate.instant(' ...

Oops! Looks like there was an issue with assigning to a reference or variable: Error: Uncaught (in promise)

I seem to be struggling with an issue that I believe may have been addressed before, but after reviewing other solutions, I am unable to pinpoint the error in my code. Any assistance in identifying my mistake would be greatly appreciated. <div class="j ...

How can I close a dialog within an iframe in jQuery?

Suppose I initiate a dialog in this way: $('<iframe id="externalSite" class="externalSite" src="http://www.example.com" />').dialog({ autoOpen: true, width: 800, height: 500, modal: true, resizable: ...

JavaScript Error: The method 'search' is not compatible with Object [object global]

Having trouble getting the 'search' function to run when the page loads, specifically encountering an error message in self.search(event). Can someone provide some guidance on how to properly call the search function upon page load? directory.vi ...

Ensuring the selected date matches any consecutive dates within the dates array in Angular

Imagine if 01/01/2022 is chosen from the input field, and my array of dates looks something like this: ['31/12/2021', '01/11/2021', '02/01/2022'...] In this scenario, when '31/12/2021' and '02/01/2022' are ...

using jquery to select elements based on their data attribute values

I have a question about using jQuery to select an object with a specific data value. For instance: $('[data-infos-parent_id=0]').html('it ok'); <div class="question" data-infos='{"parent_id":0,"my_id":0, "title":""}'> ...