Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="flex jcsa aifs f-wrap w-100vw">
		<div class="main-card m-m rubber-ipt-ctn">
			<div class="main-card-head cardhead-light flex jcc aic">
				<h5>What is your price range?</h5>
			</div>
			<div class="main-card-ctt flex jcc aic">
				<div class="rubber-ipt mb-m mt-s">
					<div class="rubber-ipt-range"></div>

					<div class="rubber-ipt-min"></div>
					<div class="rubber-ipt-max"></div>

					<div class="w-100 flex jcsb mt-s">
						<p class="rubber-value-min">10</p>
						<p class="rubber-value-max">1000</p>
					</div>
				</div>
			</div>
		</div>
	</div>
              
            
!

CSS

              
                /*  ###  Rubberband range input   */

.rubber-ipt{
	width: 200px;
	height: 2px;
	background-color: #ddd;
	position: relative;
}
.rubber-ipt-range{
	width: 200px;
	height: 2px;
	background-color: var(--main-dark);
	position: relative;
}

.rubber-ipt-min,
.rubber-ipt-max{
	height: 16px;
	width: 16px;
	border-radius: 50%;
	position: absolute;

	background-color: #fff;
	border: 1px solid var(--main-dark);
}

.rubber-ipt-min{
	transform: translate(-9px, -9px);
	left: 0;
}
.rubber-ipt-max{
	transform: translate(191px, -9px);
	left: 0;
}
.rubber-value-min{
	top:10px;
	transform: translateX(-10px);
}
.rubber-value-max{
	top:10px;
	right: 0;
	transform: translateX(10px);
}

/* #########  Styling */

body, html{
	margin: 0;
	padding: 0;
	width: 100vw;
	max-width: 100vw;
	min-width: 100vw;
	min-height: 200vh;

	background: linear-gradient(25deg,#a9f3f9, #f0fffb);
}

h1,h2,h3,h4,h5,h6,p{
	margin: 0;
	padding: 0;
}
a, a:hover{
	text-decoration: none;
	color: #000;
}

:root{
	--main-lighter: #f0fffb;
	--main-light: #a9f3f9;
	--main-sublight: #bffaff;
	--main: #00e1da;
	--main-dark: #00b7b4;
	--main-darker: #003f3c;

}

body{
	font-family: Verdana, Geneva, sans-serif;
}
h5{
	font-size: 24px;
	color: var(--main-dark);
	font-weight: 400;
}

.flex{
	display: flex;
}
.f-wrap{
	flex-wrap: wrap;
}
.jcsb{
	justify-content: space-between;
}
.jcsa{
	justify-content: space-around;
}
.jcc{
	justify-content: center;
}
.aifs{
	align-items: flex-start;
}
.aic{
	align-items: center;
}
.w-100{
	width: 100%;
}

.m-m{
	margin: 20px;
}
.mb-m{
	margin-bottom: 20px;
}
.mt-s{
	margin-top: 10px;
}


.main-card{
	max-width: 25%;
	min-width: 300px;
	border-radius: 10px;
	overflow: hidden;
	box-shadow: 0 0 8px rgba(0,0,0,0.1)
}
.main-card-head{
	background-color: var(--main-darker);
	padding: 15px 30px;
	border-radius: 10px 10px 0 0;
}
.cardhead-light{
	background-color: var(--main-lighter);
	border: 1px solid var(--main-dark);
}
.main-card-ctt{
	padding: 20px 30px 30px;
	background-color: #fff;
}
              
            
!

JS

              
                // Rubberband Input
        const rubberIpts = document.querySelectorAll(".rubber-ipt");

        for (var i = 0; i < rubberIpts.length; i++) {
            const rubberRange = rubberIpts[i].querySelector(".rubber-ipt-range");
            const rubberMin = rubberIpts[i].querySelector(".rubber-ipt-min");
            const rubberMax = rubberIpts[i].querySelector(".rubber-ipt-max");
            var initialMousePosMin;
            var initialMousePosMax;


    // Rubber Minimum
            rubberMin.style.left = '0px'
            function dragTargetMin(dragOffsetMin) {
                rubberMin.style.left = `${dragOffsetMin}px`;
            }
            function getDragOffsetMin(e) {
                if (initialMousePosMin == null) {
                    initialMousePosMin = e.clientX;
                }
                var mousePos = e.clientX;
                var dragOffsetMin = mousePos - initialMousePosMin;
                var rubberMinMax = 200 + (parseInt(rubberMax.style.left, 10)) - 10;

                if (dragOffsetMin < 0){dragOffsetMin = 0}
                else if (dragOffsetMin > rubberMinMax) {
                    dragOffsetMin = rubberMinMax;
                };
                if (dragOffsetMin > 190) {
                    dragOffsetMin = 190;
                }

                dragTargetMin(dragOffsetMin);
                updateRubberRangeMin(dragOffsetMin);
                getMinPrice(dragOffsetMin);
            }

            function SetDragStartMin(e) {
                document.addEventListener("mousemove", getDragOffsetMin);
            }
            function stopDragMin() {
                document.removeEventListener("mousemove", getDragOffsetMin);
            }

            rubberMin.addEventListener("mousedown", SetDragStartMin);
            document.addEventListener("mouseup", stopDragMin);


    // Rubber Maximum
            rubberMax.style.left = '0px'
            function dragTargetMax(dragOffsetMax) {
                rubberMax.style.left = `${dragOffsetMax}px`;
            }
            function getDragOffsetMax(e) {
                if (initialMousePosMax == null) {
                    initialMousePosMax = e.clientX;
                }
                var mousePos = e.clientX;
                var dragOffsetMax = mousePos - initialMousePosMax;
                var rubberMaxMin = (parseInt(rubberMin.style.left, 10) - 200 + 10);

                if (dragOffsetMax > 0){dragOffsetMax = 0}
                else if (dragOffsetMax < rubberMaxMin) {
                    dragOffsetMax = rubberMaxMin;
                };
                if (dragOffsetMax < -190) {
                    dragOffsetMax = -190;
                };

                dragTargetMax(dragOffsetMax);
                updateRubberRangeMax(dragOffsetMax);
                getMaxPrice(dragOffsetMax);
            }

            function SetDragStartMax() {
                document.addEventListener("mousemove", getDragOffsetMax);
            }
            function stopDragMax() {
                document.removeEventListener("mousemove", getDragOffsetMax);
            }

            rubberMax.addEventListener("mousedown", SetDragStartMax);
            document.addEventListener("mouseup", stopDragMax);


    // Update Range between Min and Max

            rubberRange.style.width = '200px';
            function updateRubberRangeMin(dragOffsetMin){
                rubberRange.style.left = `${dragOffsetMin}px`;

                var rubberRangeWidth = 200 - ((parseInt(rubberMax.style.left, 10)) * -1) - dragOffsetMin;
                if (rubberRangeWidth <= 0) {
                    rubberRangeWidth = 0;
                }
                rubberRange.style.width = `${rubberRangeWidth}px`;
            }
            function updateRubberRangeMax(dragOffsetMax){
                var rubberRangeWidth = 200 - parseInt(rubberMin.style.left, 10) - (dragOffsetMax * -1);
                if (rubberRangeWidth <= 0) {
                    rubberRangeWidth = 0;
                }
                rubberRange.style.width = `${rubberRangeWidth}px`;
            }

    // Update price range

            const minPrice = rubberIpts[i].querySelector(".rubber-value-min");
            const maxPrice = rubberIpts[i].querySelector(".rubber-value-max");

            var RubberMinPrice = 10;
            var RubberMaxPrice = 1000;

            function getMinPrice(dragOffsetMin) {
                rubberMinPrice = ((RubberMaxPrice/200) * dragOffsetMin) + (((RubberMinPrice - ((RubberMinPrice/200) * dragOffsetMin))));
                minPrice.innerHTML = `${rubberMinPrice}`

            }
            function getMaxPrice(dragOffsetMax) {
                rubberMaxPrice = ((RubberMaxPrice/200) * (dragOffsetMax + 200)) + ((RubberMinPrice - ((RubberMinPrice/200) * (dragOffsetMax + 200))));
                maxPrice.innerHTML = `${rubberMaxPrice}`

            }
        };

              
            
!
999px

Console