Creating a row of aligned vertical sliders using jQuery UI

I'm having trouble aligning multiple vertical UI sliders on the same line. Here's what I'm looking to achieve: 1. Have 4 vertical sliders displayed in a row. 2. Show numerical values as the user moves each slider.

The code I'm currently using displays the numbers on each slider. However, the sliders are stacked in a single column. How can I place them in a row?

I tried to share my code via fiddle, but ran into some issues.

Any help in resolving this issue would be greatly appreciated.

MY HTML + JS CODE:

<!doctype html>
<html lang="en">
   <head>
      <meta charset="utf-8>
      <title>jQuery UI Slider functionality</title>
      <link href="http://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet">
      <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
      <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
      <!-- Javascript -->
      <script>
         $(function() {
            $( "#slider-4" ).slider({
               orientation:"vertical" 
            });
            $( "#slider-4" ).slider({
               orientation:"vertical",
               value:50,
               slide: function( event, ui ) {
                  $( "#minval4" ).val( ui.value );
               }  
            });
            $( "#minval4" ).val( $( "#slider-4" ).slider( "value" ) );
            $( "#slider-5" ).slider({
               orientation:"vertical",
               value:50,
               slide: function( event, ui ) {
                  $( "#minval5" ).val( ui.value );
               }  
            });
            $( "#minval5" ).val( $( "#slider-5" ).slider( "value" ) );
         });
      </script>
      <!-- Your code here -->
      <style>
        [id^="slider-"] + p {
            float: left;
            margin-right: 1em;
          }
      </style>
   </head>
   <body>
      <!-- HTML --> 
         <div class="container">
         <div id="slider-4"></div>
         <p>
            <label for="minval4">Minumum value4:</label>
            <input type="text" id="minval4" 
               style="border:0; color:#b9cd6d; font-weight:bold;">
         </p>
         <div id="slider-5"></div>
         <p>
            <label for="minval5">Minumum value5:</label>
            <input type="text" id="minval5" 
               style="border:0; color:#b9cd6d; font-weight:bold;">
         </p>
       </div>
   </body>
</html>

Answer №1

To start, I separated each slider and <p> element into their own designated sections:

  <div class="container">
     <section class="slider">
        <div id="slider-4"></div>
        <p>
           <label for="minval4">Minimum value4:</label>
           <input type="text" id="minval4" 
              style="border:0; color:#b9cd6d; font-weight:bold;">
        </p>            
     </section>
     <section class="slider">
        <div id="slider-5"></div>
        <p>
           <label for="minval5">Minimum value5:</label>
           <input type="text" id="minval5" 
              style="border:0; color:#b9cd6d; font-weight:bold;">
        </p>            
     </section>
   </div>

Afterwards, I included this CSS just before closing the </head> tag:

  <style>
    section.slider {
     float: left;
    }
  </style>

Snippet: https://gist.github.com/antibland/6c43a6f20d5fce3a3bc8ad7324731516

https://i.sstatic.net/HscO8.gif

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

Finding a specific element within a Node.js application requires pinpointing and isolating

I have a dynamic table that displays user information, with each row containing an update icon and a delete icon. When the delete icon is clicked, I need to delete the corresponding user record. The challenge is identifying which user's delete icon ha ...

Increasing a local variable in the view using ASP.NET

Despite its seeming simplicity, I'm struggling to find the solution to this problem. When adding a number (like 2) to a page variable, it's being recognized as a string and displaying: instead of 3 : 1+2 @{ var page= 1 ; } <li>@ ...

Prevent users from selecting an option depending on a specific criteria

I need help with disabling select options based on specific time instances. For example, I want the user to provide specifications by 6:00 am in order to use the system at 10:00 am, ensuring there is a 4-hour gap between the two times. So, after 6:00 am, t ...

Encountering an undefined property error while using Array.filter in Angular 2

hello everyone, I am currently faced with an issue while working on a project that involves filtering JSON data. When using the developer tools in Chrome, it keeps showing me an error related to undefined property. chart: JsonChart[] = []; charts: JsonC ...

Concealing and wrapping text using CSS in a table structure

My table is displayed below: <table style="width: 100%; white-space: nowrap; overflow: hidden;"> <tbody><tr> <th> Department </th> <th> Function </th> ...

Promise chain failure in express

I've developed an express.js server for managing REST API requests and extracting data from a MongoDB database. However, I'm encountering an issue with the promise chain when I send a GET request to a specific endpoint ("localhost:8081/api/getUse ...

Spread out a div across a container's width

Currently, I am struggling to modify my css and html in order to have a div expand horizontally into a scrollable div. However, all I seem to get is the content stacking once the width limit is reached. Take a look at this fiddle for reference. The absol ...

Unable to get CSS transition to function properly after adding a class using jQuery

I am trying to create a hover effect that shows an image when the mouse is over a specific div, but for some reason, the transition is not working as expected. I understand that using visibility: hidden cannot be animated. Here is the code snippet: $(d ...

Adjust the size of a canvas using JavaFX in an FXML file

I am encountering an issue with resizing a canvas in Javafx while using scene builder and fxml. Currently, when the user clicks on the canvas, it turns black, but upon resizing the screen and clicking on the canvas again, only the original size of the canv ...

Ways to retrieve information when text is modified and a dropdown is selected within an input field

I have an input field with a text box and a dropdown. My goal is to trigger data based on text changes in one method, while using another method for the dropdown. Check out the code below. const allList = [ { id: "1", value: "Fruits" ...

Adjust the slide count accordingly when navigating to a particular item within the Bootstrap 3 Carousel

I made adjustments to the standard Bootstrap 3 Carousel so that it can navigate to a specific slide when the URL matches #. Although this feature is working, I am facing an issue with my pager-text not updating correctly when jumping to a specific slide. T ...

Is it possible to incorporate a jQuery widget within a table?

Can the jQuery sortable widget be utilized within a table, or is it designed to function separately? Here is the link to the jQuery widget for reference - http://jqueryui.com/sortable/#default ...

Expression Engine presents a dilemma with breadcrumbsOr:Expression Engine

Having a slight issue with Expression Engine. I've created a breadcrumb snippet using {if segment_} coding. While setting up if rules for each page on the small site, I encountered a problem with one of the breadcrumb trials. The issue arises when tr ...

"Enhancing Hangman by updating the object-oriented array of values

I'm currently working on developing a hangman game using PHP and JS, but I've encountered some issues. In my project, there are two arrays involved - the answer array containing the correct letters and the user answer array storing the user' ...

Enemy in Three.js advances menacingly towards the player

I'm working with three.js and I've got a spaceship located at coordinates xyz. I want it to fly towards a mesh object representing a planet at coordinates xyz. I've been struggling to figure this out and it's been quite challenging. T ...

Stop the execution of jQuery ready handlers

I am facing a situation where I need to prevent jQuery ready handlers from firing on the DOMContentReady event under certain conditions. These handlers are set up in different places like include files, plugins, and more. While one approach could involve s ...

Unable to access JSON data from LocalStorage using jQuery

Currently, I am encountering an issue while attempting to save a JSON array in jQuery to localStorage for future use. Unexpectedly, whenever I make the attempt to save it, an error indicating that the object is not defined arises. Below is my present code: ...

What is preventing my div from reaching 100% height when I implement an HTML5 doctype? Is there a solution to achieving a full height div?

I'm currently working on organizing the layout for a basic gallery webapp, and I've encountered an issue where some of my divs are shrinking in height when using an HTML5 doctype declaration. Despite trying different CSS properties, I can't ...

What is causing my css elements to appear larger compared to other instances?

As someone who is not a designer, I find myself doing a lot of cutting and pasting for my side hustles. I believe many others can relate to this experience. Currently, I am working on a personal project that involves using tailwindcss, appwrite, and svelte ...

The createElement function in Vue.js does not always return a fully formed component

There is a scenario where I need to create a functional component for a specific purpose. The task at hand involves taking all the children elements and adding some additional props to them, but only to those that are custom components of type ChildCompone ...