Custom scrollbar only in one div - html

I want to have a custom scroll bar in Chrome.
So, I'm using this sass:
::-webkit-scrollbar {
width: 0.5em;
height: 0.5em;
}
::-webkit-scrollbar-thumb {
background-color: rgba(255,255,255,.1);
border-radius: 3px;
&:hover {
background: rgba(255,255,255,.2);
}
}
My problem is that I want this scrollbar style only in an specific div. But if I do:
#boardslist {
::-webkit-scrollbar {
width: 0.5em;
height: 0.5em;
}
::-webkit-scrollbar-thumb {
background-color: rgba(255,255,255,.1);
border-radius: 3px;
&:hover {
background: rgba(255,255,255,.2);
}
}
}
is not working. Any ideas?

#boardslist {
&::-webkit-scrollbar {
width: 0.5em;
height: 0.5em;
}
&::-webkit-scrollbar-thumb {
background-color: rgba(255,255,255,.1);
border-radius: 3px;
&:hover {
background: rgba(255,255,255,.2);
}
}
}
Check this out http://codepen.io/tholman/pen/tldwm

If you are doing it for a class, you can do it in the following way. Side bar is the class given to the div that you want to allow scrolling.
.side_bar{
padding-right: 20px;
margin-left: -12px;
position: sticky;
top: 0;
height: 100vh;
overflow-y: scroll;
/* width */
}
.side_bar::-webkit-scrollbar {
width: 5px;
}
/* Track */
.side_bar::-webkit-scrollbar-track {
box-shadow: inset 0 0 2px grey;
border-radius: 10px;
}
/* Handle */
.side_bar::-webkit-scrollbar-thumb {
background: rgb(7, 7, 7);
border-radius: 10px;
}
/* Handle on hover */
.side_bar::-webkit-scrollbar-thumb:hover {
background: #009eb3;
}

It's 2020 and ::-webkit-scrollbar is still not supported in Firefox.
Besides overflow:auto shows scrollbar when content overflows in Chrome and Safari, but in Firefox there will be no visible scrollbar until we start scrolling. Go guess whether content is scrollable or not. Same with overflow:scroll. Not very intuitive.

Well, 2022 and still no support in Firefox: https://caniuse.com/?search=%3A%3A-webkit-scrollbar
However, basics can be customized in Firefox:
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Scrollbars
https://caniuse.com/?search=scrollbar-color
/* Chrome */
.container::-webkit-scrollbar {
width: 5px;
}
.container::-webkit-scrollbar-track {
/*background-color: grey;*/
box-shadow: inset 0 0 5px grey;
border-radius: 15px;
}
.container::-webkit-scrollbar-thumb {
background-color: orange;
border-radius: 15px;
/*border: 1px solid red;*/
}
/*.container::-webkit-scrollbar-button {
background-color: red;
border-radius: 15px;
}*/
.container::-webkit-scrollbar-thumb:hover {
background: red;
}
/* IE */
.container {
scrollbar-face-color: orange;
scrollbar-shadow-color: grey;
scrollbar-highlight-color: red;
}
/* FireFox */
.container {
scrollbar-color: orange grey;
scrollbar-width: thin;
}
/* View Scrollbar */
.container {
overflow-y: scroll;
overflow-x: hidden;
width:400px;
height: 200px;
}
Working example is here:
https://codepen.io/svigir/pen/LYOOjyj

Related

IOS / Android / Windows HTML range slider inconsistency

I have the following vertical range slider setup.
Codepen LINK
Example here:
body{
display: flex;
justify-content:space-evenly;
align-items:center;
align-content:start;
flex-wrap:wrap;
width: 100%;
height: 100vh;
overflow:hidden;
}
:root{
--shader_top_half_color: cornflowerblue;
--shader_thumb_color: #5e7cd3;
--group_shader_top_half_color: #4bcca1;
--group_shader_thumb_color: #4cbb9f;
}
.shaderRangeWrapper {
width: 100px;
display: flex;
flex-direction: column;
gap: 45px;
justify-content: center;
align-items: center;
margin-top: 35px;
-webkit-tap-highlight-color: transparent;
position: relative;
}
input.shaderRange {
-webkit-tap-highlight-color: transparent;
transform: rotate(90deg);
height: 100px;
width: 150px !important;
margin: 0px;
padding: 0px;
-webkit-appearance: none;
background: transparent;
touch-action: none;
overflow: hidden;
border-radius: 0.5rem;
box-shadow: rgba(0, 0, 0, 0.16) 0px 10px 36px 0px, rgba(0, 0, 0, 0.06) 0px 0px 0px 1px;
}
/* REMOVE BASIC STYLES */
.shaderRange::-webkit-slider-thumb {
-webkit-appearance: none;
}
.shaderRange:focus {
outline: none;
}
.shaderRange::-ms-track {
width: 100%;
cursor: pointer;
background: transparent;
border-color: transparent;
color: transparent;
}
/* STYLE THE THUMB FOR SPECIFIC BROWSERS */
/* Special styling for WebKit/Blink */
.shaderRange::-webkit-slider-thumb {
-webkit-appearance: none;
height: 90px;
width: 10px;
border-radius: 0.5rem;
background: var(--shader_thumb_color);
cursor: pointer;
margin-top: 5px;
box-shadow: -80px 0 0 75px var(--shader_top_half_color);
/* You need to specify a margin in Chrome, but in Firefox and IE it is automatic */
}
/* All the same stuff for Firefox */
.shaderRange::-moz-range-thumb {
height: 90px;
width: 10px;
border-radius: 0.5rem;
background: var(--shader_thumb_color);
cursor: pointer;
margin-top: 5px;
box-shadow: -80px 0 0 75px var(--shader_top_half_color);
}
/* All the same stuff for IE */
.shaderRange::-ms-thumb {
height: 90px;
width: 10px;
border-radius: 0.5rem;
background: var(--shader_thumb_color);
cursor: pointer;
margin-top: 5px;
box-shadow: -80px 0 0 75px var(--shader_top_half_color);
}
/* STYLE THE TRACK FOR SPECIFIC BROWSERS */
.shaderRange::-webkit-slider-runnable-track {
height: 100px;
height: 100px;
cursor: pointer;
background: transparent;
border-radius: 0.3rem;
}
.shaderRange:focus::-webkit-slider-runnable-track {
background: transparent;
}
.shaderRange::-moz-range-track {
height: 100px;
height: 100px;
cursor: pointer;
background: transparent;
border-radius: 0.3rem;
}
.shaderRange::-ms-track {
height: 100px;
height: 100px;
cursor: pointer;
background: transparent;
border-radius: 0.3rem;
}
/* GROUP SHADER STYLE */
/* Special styling for WebKit/Blink */
.shaderRange.groupShaderRange::-webkit-slider-thumb {
-webkit-appearance: none;
height: 90px;
width: 10px;
border-radius: 0.5rem;
background: var(--group_shader_thumb_color);
cursor: pointer;
margin-top: 5px;
box-shadow: -80px 0 0 75px var(--group_shader_top_half_color);
/* You need to specify a margin in Chrome, but in Firefox and IE it is automatic */
}
/* All the same stuff for Firefox */
.shaderRange.groupShaderRange::-moz-range-thumb {
height: 90px;
width: 10px;
border-radius: 0.5rem;
background: var(--group_shader_thumb_color);
cursor: pointer;
margin-top: 5px;
box-shadow: -80px 0 0 75px var(--group_shader_top_half_color);
}
/* All the same stuff for IE */
.shaderRange.groupShaderRange::-ms-thumb {
height: 90px;
width: 10px;
border-radius: 0.5rem;
background: var(--group_shader_thumb_color);
cursor: pointer;
margin-top: 5px;
box-shadow: -80px 0 0 75px var(--group_shader_top_half_color);
}
<div class="shaderRangeWrapper">
<input type="range" min="0" max="100" class="shaderRange">
<span class="shaderRangeName">Test 1</span>
</div>
On Android and Windows, i can click/tap anywhere on the slider and the thumb will follow my finger/cursor from where i clicked/tapped and it will not trigger a change until i release it. On IOS ( tested on Iphone 7 plus, 8 and X ) i can only slide the range if i manage to hit the thumb. If i miss tap and did not hit the slider's thumb, the slider will trigger a change and the thumb will not follow my tapping. How can i make this consistent on platforms?
HERE IS A DRIVE LINK To A VIDEO DEMONSTRATING THE GOOD BEHAVIOUR ON ANDROID AND THE BAD ON IOS
EDIT: The bad behaviour description was wrong. On IOS if i miss the thumb, it will not trigger a change, but the thumb will not follow my finger and i don't know where it is. Often times it does not change the range at all if i release it.

How to correctly customize the drop-down menu created by ul-li tags?

I created a drop-down menu using tags ul and li. This works, but I want that when opening the menu, it does not shift the blocks below like on screen. So, this is my css:
#select-ul {
display: block;
cursor: pointer;
border: 0.1px solid rgba(0, 0, 0, .1);
border-top: 0;
background-color: white;
padding: 12px;
height: 300px;
overflow: auto;
float: none;
overflow-y:scroll;
}
Change your css a bit like
OLD CSS
#select-ul {
display: block;
cursor: pointer;
border: 0.1px solid rgba(0, 0, 0, .1);
border-top: 0;
background-color: white;
padding: 12px;
height: 300px;
overflow: auto;
float: none;
overflow-y:scroll;
}
NEW CSS
#select-ul {
z-index: 1;
display: none;
position: absolute;
width: 100%; /* you can change but must give width */
max-height: 300px;
cursor: pointer;
border: 1px solid #e5e5e5; /* 0.1px doesn't work */
border-top: 0;
padding: 12px;
background-color: white;
overflow: hidden scroll;
}
#select-ul.active {
display: flex;
flex-direction: column;
}
And a bit JavaScript convert it in vue as you are using it.
const dropdown = document.querySelector('#select-ul');
dropdown.addEventListener('click', () => {
dropdown.classList.add('active'); // you can also use toggle
});
// additionally
dropdown.addEventListener('blur', () => {
dropdown.classList.remove('active');
});
Lemme know if this work! TBH I am not getting what scaling issue you are talking about. *elaborate it some more.

Pure CSS range slider whose background color changes based on progress/value

I've been looking to build a range slider which changes the background color of the filled portion based on the current progress value. For example, be greener if closer to 0, yellow in the middle and gets more red towards the maximum value.
This is the current CSS for my slider:
#media screen and (-webkit-min-device-pixel-ratio:0) {
input[type='range'] {
overflow: hidden;
width: 80px;
-webkit-appearance: none;
background-color: white;
border: 1px #e1e4e8 solid;
outline-width: 0;
}
input[type='range']::-webkit-slider-runnable-track {
height: 10px;
-webkit-appearance: none;
color: red;
margin-top: -1px;
}
input[type='range']::-webkit-slider-thumb {
width: 4px;
-webkit-appearance: none;
height: 10px;
background: #24292e;
box-shadow: -80px 0 0 80px red;
}
}
/* FF */
input[type="range"]::-moz-range-progress {
background-color: red;
}
input[type="range"]::-moz-range-track {
background-color: white;
}
/* IE */
input[type="range"]::-ms-fill-lower {
background-color: red;
}
input[type="range"]::-ms-fill-upper {
background-color: white;
}
I'm not sure if this can be done with just CSS, but I'd prefer to not use JS at all. I believe that with some browser-specific elements it may be possible?
Thanks

Fixing opacity of content inside div

I have a div that has a background image but has 50% opacity.
Now I have a div that is child and I want what every the content it has to have 100% opacity. You can see in the snipplet headings and textbox and button has less opacity.
Can anyone help how to fix this thing? I tried to apply opacity 100% to child but it didn't work.
/* CSS to be fixed*/
#home_div
{
background-image: url("https://upload.wikimedia.org/wikipedia/commons/thumb/1/1e/Shoppers_on_Dundas%2C_near_Yonge.jpg/1200px-Shoppers_on_Dundas%2C_near_Yonge.jpg");
opacity: 0.5;
filter: alpha(opacity=50);
/*background-color: #0050A0;*/
background-color: lightgrey;
padding-top: 200px;
color: white;
padding-bottom: 200px;
height: 100%;
}
#home_div_content
{
opacity: 1.0;
filter: alpha(opacity=100);
text-align: center;
}
#header
{
height: 70px;
border-bottom: 4px solid lightgrey;
}
#header_content
{
margin-top: 10px;
margin-left: 80px;
}
.brandmark
{
margin-top: -20px;
}
.link_to a
{
color: #0050A0 !important;
}
.featured_div
{
display: none;
}
.featured_close_anchor, .featured_anchor_close
{
text-align: center;
}
#heading, #tag_line
{
top: -300px;
position:relative;
color: #0050A0;
}
#search
{
border-radius: 0 !important;
border-color: #0050A0 !important;
width: 60%;
height: 35px;
padding: 8px 15px;
color: #0050A0; /* change color of text to be typed inside search box */
font-size: 13px;
line-height: 20px;
background-color: transparent;
border: 1px solid #ccc;
-webkit-box-shadow: none;
box-shadow: none;
}
.btn-custom {
color: #FFFFFF;
background-color: #0050A0; /* change button color */
border-radius: 0!important; /* button border radius */
padding: 5px 11px; /* Button size change*/
margin-top: -3.5px;
border-top: 2px solid #0050A0;
border-bottom: 3px solid #0050A0;
margin-left: -3px;
}
.btn-custom:hover{
background-color:#9AC94B; /* change button color on hover */
border-radius: 0!important;
}
.left_categories
{
padding-top: 5px;
padding-bottom: 5px;
margin-bottom: 1px;
border-left: 4px solid #0050A0;
}
.left_categories:hover
{
border-top: 1px solid lightgrey;
border-bottom: 1px solid lightgrey;
border-left: 4px solid #E5002B;
}
.active_category
{
background-color: #0050A0;
color: white !important;
border-left: 4px solid #E5002B;
}
.search_section
{
margin-top: 30px;
}
a
{
text-decoration: none !important;
}
.flash_nav
{
height: 90px;
border: 0 !important;
background-color: #283442;
}
.gradient
{
background: -moz-linear-gradient(left, white 0%, white 45%, #12A8E0 85%, #0050A0 100%);
}
.flash_navbar a
{
color: black !important;
}
.search_form
{
width: 70%;
}
.nav_form
{
border-radius: 0;
margin-top: 27px;
}
#searchBar
{
border-color: #0050A0;
}
#searchButton
{
background-color: #0050A0;
color: white;
border: none;
}
<div id="home_div">
<div class="container" id="home_div_content">
<h1 id="heading">Find your product!</h1>
<h4 id="tag_line">Search what you are looking for.</h4>
<form method="GET" action="/product/search">
<input type="text" name="product" id="search" placeholder="Enter product name" class="searchTextBox" />
<button type="submit" id="quick-search" class="btn btn-custom"><span class="glyphicon glyphicon-search custom-glyph-color"></span></button>
</form>
<br />
view <i class="fa fa-chevron-down"></i> featuring
</div>
</div>
FIDDLE
An opacity rule will always affect child/descendant elements since they are part of the parent, and the rule says the parent should be 50% opacity.
To get round this, use a pseudo element and give that reduced opacity rather than the parent.
HTML
<div id='outer'>
<div id='inner'></div>
</div>
CSS
#outer { width: 200px; height: 200px; position: relative; padding: 2em; }
#outer::before { content: ''; position: absolute; left: 0; top: 0; width: 100%; height: 100%; background: red; opacity: .5; z-index: -1; }
#inner { width: 100%; height: 100%; background: blue; }
Fiddle.

How to change scrollbar style in bootstrap tooltip

I have a tooltip and I don't know how to change color on scrollbar.
.tooltip-inner {
font-size: smaller;
white-space: pre-line;
width: 200px;
height: 200px;
overflow-y: auto;
}
you can find all infomations right there css-tricks.
But remember that IE and Firefox doesn't support it.
Example as suggested:
body::-webkit-scrollbar {
width: 1em;
}
body::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
}
body::-webkit-scrollbar-thumb {
background-color: darkgrey;
outline: 1px solid slategrey;
}
For your code try this:
.tooltip-inner::-webkit-scrollbar {
width:15px;
}
.tooltip-inner::-webkit-scrollbar-track {
background-color:#FFFFFF;
}
.tooltip-inner::-webkit-scrollbar-thumb {
background-color:#2A2A2A;
border-radius:10px;
border-style:solid;
border-width:4px;
border-color:#FFFFFF;
}
I only changed body to your class, it should work like this.