I drew in photoshop what I want to
There is a 40px indent and a blackout at the bottom. There is also a 40px indent at the end of the block. If, for example, the indentation can be arranged with a border, then if there is no border at the bottom, but a conditional padding, then the scrollbar will be at the bottom of the block, and I need it to be limited to the bottom and top by 40px.
Again, I need the text to be visible at the top when scrolling as well. So I can’t use the border at all.
In short, I can’t limit the scrollbar height or make it, so that the text is visible…One or the other… Is there any way to organize this in css?
I can deal with the appearance and disappearance of the fade in and out with js.
.block {
box-sizing: border-box;
width: 600px;
height: 90%;
background: #dfdfdf;
font: 24px/36px Arial;
overflow: auto;
border:30px solid #dfdfdf;
position: absolute;
margin: auto;
top:0;
left:0;
right:0;
bottom:0;
}
.block::-webkit-scrollbar {
width: 10px;
height: 10px;
border-radius: 20px;
background: #aeaeae;
}
.block::-webkit-scrollbar-thumb {
background: #ffffff;
border-radius: 10px;
cursor: pointer;
}
.block::-webkit-scrollbar-corner {
background: rgba(0,0,0,0);
}
<div class="block">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
2
Answers
I did add a wrapper and use some pseudo element.
The answer has been inspired from similar subject: Change scrollbar height
The main idea is to hide the scrolling
track
as it is too long and reduce thethumb
size.Then, you add a "fake" track which has a good height (
wrapper:before
).The background part is tricky but has been defined with (
wrapper:after
).I added the fade using
.layer
if you dont like it you can remove it or change color how you want.DEMO