How can I conceal the range input button in Bootstrap 4?

Below is the html code snippet that I currently have:

<form>
  <div class="form-group">
    <label for="formControlRange">Example Range input</label>
    <input type="range" class="form-control-range" id="formControlRange">
  </div>
</form>

This code was taken from bootstrap 4 documentation (https://getbootstrap.com/docs/4.1/components/forms/#range-inputs) and it generates a result like this: https://i.sstatic.net/juVKW.png

I am looking to make the button hidden until someone interacts with the range input. Is there a way to achieve this?

Additionally, I plan on implementing this range input into my oTree code:

<label class="col-form-label">
    Pizza is the best food:
</label>

<div class="input-group">
    <div class="input-group-prepend">
        <span class="input-group-text">Disagree</span>
    </div>

    <input type="range" name="pizza" min="1" max="5" step="1" class="form-control">

    <div class="input-group-append">
        <span class="input-group-text">Agree</span>
    </div>
</div>

The above code snippet was taken from the oTree documentation:

Answer №1

An alternative solution using only HTML and CSS, without the need for JavaScript:

<label class="col-form-label">
   Pizza is the best food:
</label>
<div class="input-group">
    <div class="input-group-prepend">
        <span class="input-group-text">Disagree</span>
    </div>
    <div class="range">
        <input type="range" name="pizza" min="1" max="5" step="1" class="form-control 
        range-input">
    </div>
    <div class="input-group-append">
        <span class="input-group-text">Agree</span>
    </div>
</div>

Modified the styling to remove platform-specific design and added custom CSS properties. Feel free to customize further to suit your needs.

.range-input {
  -webkit-appearance: none;
  -moz-appearance: none;
  border-radius: 26px;
  height: 10px;
  width: 170px;
  background-color: rgb(74, 123, 197);
}

.range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 0;
  height: 0;
}

.range:active .range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 20px;
  height: 20px;
  border: 1px solid blue;
  border-radius: 50%;
  background: #fff;
  box-shadow: 1px 2px 3px rgba(0, 0, 0, 0.6);
}

Visit this link for a demonstration of the code in action.

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

"Customizing the appearance of Angular Formly forms by adding classes to the surrounding div element

<formly-form model="vm.model" fields="step.inputs" options="vm.options"> <div style="text-align:right"> <button type="submit" wz-next class="btn btn-primary submit-button" ng-disabled="innerForm.$invalid">Next</button> ...

Angular Jasmine error: Attempting to broadcast within a timeout when 'undefined' is not an object

Here's a function I've been working with: $scope.doIt = function( x, y ) { $timeout( function () { $rootScope.$broadcast( 'xxx', { message: xxx, status: xxx } ); } ); } The function appears ...

What is the best way to show my button only when within a specific component?

Is there a way to display the Logout button on the same line as the title only when the user has reached the Home component? In simpler terms, I don't want the logout button to be visible all the time, especially when the user is at the login screen. ...

Tips on sending the event object as the second parameter to a callBack function

I am looking to enhance a callback function by including the execution of event.stopPropagation() on the specific div element where it is called, alongside updating the state. QueryInput represents a custom input div element for adding text provided by the ...

Event listener for clicking on a custom overlay in Google Maps

Incorporating Google Maps into an Ionic project, I have successfully added a custom overlay to display the address of a marker location on top of the map. By adding a click event listener to the map, I can detect clicks and update the marker for new locat ...

Storing array data locally within an AngularJS application for seamless sharing between two separate applications

I need assistance with persisting and sharing array data var queries = []; between two separate AngularJS applications. One application is for the front end, while the other is for the admin side. Both applications cause the entire page to load when access ...

Using Zurb Foundation modal instead of Rails confirm causes an error: "Uncaught TypeError: confirmWithReveal is not a function"

I must admit, my skills in javascript are lacking. Please excuse me if I overlook something obvious. My goal is to replace the standard confirm dialog with the Foundation modal dialog. Can anyone guide me on how to implement this correctly on my page? Her ...

Using Nodes to Populate an Array with References to Objects

How can I populate the courses of a Student in StudentSchema with courses (Object_id) from Course in CourseSchema that belong to the same major as the student? let StudentSchema = new Schema({ _id: new Schema.Types.ObjectId, emplId: { type: ...

What is the process for turning off bootstrap form validation?

I am facing an issue with utilizing the default input email validation in my development project. It seems that Bootstrap, which is being used for the website, has its own validation mechanism. Whenever I begin typing in a Bootstrap input field, an error m ...

The functionality of Angular's $window.scrollTo() seems to be malfunctioning

After successfully finding a specific element on my Angular app's page, I am attempting to scroll to it. However, despite trying both $window.scrollTo() and window.scrollTo(), the scrolling action is not being executed as expected. My console does log ...

Steps for adding a PHP dropdown menu to an HTML/Javascript webpage

Hey there, this is only my second post and I have to admit that I am a newbie in the world of web development. I'm spending countless hours scouring different websites for guidance, and I'm finally starting to grasp some concepts (at least for no ...

How can I upload an image file using VueJS and Django Rest Framework?

Hello, I am currently in the process of editing a blog page using VueJS and Django Rest Framework. However, I am facing an issue when trying to upload a photo - I keep receiving an error message stating that "the sent data is not a file." Additionally, I a ...

Incorporating React-Native components into a Next.js application within an Nx monorepository: A Step-by-Step

I'm encountering an issue while attempting to integrate React Native components into an Nx monorepo setup. Initially, the Nextjs app compiles successfully: info - Fast Refresh enabled for 1 custom loader event - client and server compiled successful ...

Validation of select inputs in Bootstrap 4 using bootstrap-validate

I have been using the bootstrap-validate plugin for Bootstrap 4, which can be found here. Currently, I am attempting to validate a select input in the following way: <div class="form-group"> <label for="numberOfBedrooms">Number of Bedroom ...

Utilizing PHP loops to dynamically generate Bootstrap rows with specific column configurations for elements

My goal is to design a front-end layout using a PHP loop along with Twitter Bootstrap's 12 column grid system: https://i.sstatic.net/nvFC6.jpg This is the HTML output: <div class="row"> <div class="col-lg-4"> Content... ...

Sending PHP data to an email composed in HTML

When sending an HTML email to my users using inlined CSS mixed with the HTML, I encounter a problem. How can I pass my variables from PHP to the HTML and use them accordingly when sending the email? For example, the email is supposed to contain the user&ap ...

Unlocking the Power of ASP.NET C# for Adding HTML in Code Behind

How do I input HTML in the code behind? This is the HTML code I have: <table style="width:100%"> <tr> <th>Product</th> <th>Price</th> <th>Edit</th> </tr> <!-- I need to insert ...

Tips for positioning a Wordpress navigation bar to the right of a logo

My goal is to position the navigation bar next to the logo in my Wordpress theme using Underscores. I have successfully aligned the primary navigation and the logo as desired with the following CSS: .main-navigation { position: relative; float: ri ...

CSS3 problem with using transparent PNGs as border images

Currently, I am implementing the border-image property using a PNG image that contains a transparent section. The issue arises when the background-color of the div is set to black. Upon applying the border-radius, the transparent section of the pattern dis ...

"Encountered an issue while attempting to access properties that are undefined, specifically with the operation 'includes

I'm encountering a specific error message TypeError: Cannot read properties of undefined (reading 'includes') while running my test in React. The issue seems to be related to a line in my code where the test fails to progress, but commenting ...