/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Box around html5 range slider

I would like to draw a visual box of 2px solid blue around an HTML5 range slider, but the bordered div does not seem to draw correctly around it.

[code=html]
<form oninput=”output.value=slider.value”>
<div id=”box”>
<input id=”slider” type=”range” min=”1″ max=”11″ name=”tap”>
</div>
<output id=”output”>5</output>
</form>
[/code]

[CODE]
input[type=”range”]{
width: 500px;
margin: 10px;

color: blue;
font-family:cursive;
font-size: 2em;
}

input[type=”range”]::before {
content: attr(min);
}
input[type=”range”]::after {
content: attr(max);
}

#output {
display: block;
margin-top: 30px;

color: orange;
font-size: 1.5em;
}

#box {
width: 500px;
border: 2px solid blue;
border-radius: 10px;
}
[/CODE]

When I inspect the slider, I see this: [url]http://oi64.tinypic.com/21bq1ie.jpg[/url] It seems like either the box div isn’t aware of the slider or the other way around.

What’s the problem here?

to post a comment
CSS

2 Comments(s)

Copy linkTweet thisAlerts:
@tracknutMar 27.2016 — It looks to me like you're trying to stuff a 520px input field into a 500px box. So the input is overflowing.
Copy linkTweet thisAlerts:
@33303authorMar 27.2016 — You are exactly right. I thought that changing the border-box on the slider would fix it, but then I read in the documentation that 'box-sizing: border box' doesn't include margins. Changing the size of my box div to 520px fixed the problem.

Thanks tracknut.
×

Success!

Help @33303 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...