How can I eliminate the tiny white square located beneath the scrollbar track?

`::-webkit-scrollbar{
    width: 12px;
}

body::-webkit-scrollbar-track{
    background: #f1e9e9;
    border-radius: 10px;
    margin-block: 0.1875rem;
}

::-webkit-scrollbar-thumb{
    background-color: #582965;
    border-radius: 10px;
    border: 3px solid #ffffff;
}

::-webkit-scrollbar-thumb:hover{
    background-color: #40144d;
}

::-webkit-scrollbar-track:horizontal{
    display: none;
}`

This snippet of code was created to style a scrollbar in CSS and despite its functionality, an inexplicable white square appears below the scrollbar. Any insights or suggestions on how to troubleshoot this issue would be greatly appreciated. For those interested in delving deeper into the project's codebase, feel free to visit this link.

Here is an image depicting the issue: https://i.sstatic.net/mRMoG.png

I have exhausted all possible solutions that come to mind, but the problem persists.

Answer №1

Due to the presence of "overflow:scroll" for both horizontal and vertical axes, a small white square appears where they intersect. https://i.sstatic.net/jKwjR.png

Instead, use

overflow-y:scroll

and eliminate the need for

::-webkit-scrollbar-track:horizontal{
   display: none;
}

Answer №2

The intersection of both scrollbars creates the corner on a webpage. If you have enabled scrolling in both directions, this corner will be visible. In browsers that support WebKit, you can customize the appearance of this corner using CSS.

::-webkit-scrollbar-corner {
    background-color: transparent ; 
}

::-webkit-scrollbar-corner {
    /* Set the background color to yellow for visibility */
    background-color: yellow ;
}
<div style="width:200px; height:200px; overflow:auto;background-color:red">
    <div style="height:500px; width:200px; background-color:blue"></div>
</div>

Answer №3

When it comes to creating a vertically scrollable div, the W3 doc suggests:

To achieve a scrollable bar, utilize the x and y-axis. Set overflow-x: hidden; and overflow-y: auto; to hide the horizontal scrollbar while showing the vertical one automatically.

The information provided by the MDN web docs on overflow-y is as follows:

The overflow-y CSS property determines how content appears when it overflows a block-level element's top and bottom edges. It can be nothing, a scroll bar, or the overflowing content itself. This property can also be specified using the overflow shorthand property.

https://i.sstatic.net/wNXg3.jpg

Looking at The Overflow Property (which showcases a similar issue you might be facing) versus The overflow-y Property. To address your specific case, simply add a line like this:

main .description {
max-height: 5rem;
font-size: 14px;
padding-right: 0.625rem;
overflow-y: scroll; /****----- allow vertical scroll only -----****/
}

The code snippet below demonstrates how this property works in practice:

const toggleThemeButton = document.getElementById("theme-toggle-button");
const body = document.querySelector("body");
const themeToggleButtonImage = document.querySelector(".toggle-button-image");

toggleThemeButton.addEventListener("click", () => {
  const darkModeActive = body.classList.contains("dark-mode");

  body.classList.toggle("dark-mode");

  if (darkModeActive) {
    themeToggleButtonImage.setAttribute("src", "./src/images/sun.png");
  } else {
    themeToggleButtonImage.setAttribute("src", "./src/images/moon.png");
  }
});
/****----- RESET -----****/
*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

ul{
    list-style: none;
}

/****----- MAIN -----****/

body{
    font-family: 'Poppins', sans-serif;
    max-width: 80rem;
    margin: 0 auto 0 auto;
    background-color: #5e5b5bad;
    color: #333333;
}
body.dark-mode{
    background-color: #212121;
    color: #f5f5f5;
}

header{
    display: flex;
    justify-content: space-between;
    padding: 1.5625rem;
}

header .logo,
header .toggle-button-image{
    width: 1.875rem;
    transition: 0.2s ease-in-out;
}

header #theme-toggle-button{
    background: none;
    border: none;
}

header .logo:hover,
header .toggle-button-image:hover,
main .pokemon-card:hover{
    transform: scale(1.05);
    cursor: pointer;
}

main{
    padding: 1.5625rem;
}

main .pokemon-list {
    display: flex;
    flex-wrap: wrap;
    gap: 1.875rem;
    justify-content: center;
}

main .pokemon-card{
    background-color: #d8e3ec;
    width: 12.5rem;
    padding: 0.9375rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.9375rem;
    border-radius: 15px;
    transition: 0.2s ease-in-out;
}

main .pokemon-card:hover{
    background-color: #96d9d6;
}

.dark-mode .pokemon-card {
    background-color: #a8a8a8;
}

main .pokemon-card .information{
    display: flex;
    justify-content: space-between;
    border: 0.0625rem solid #333333;
    border-radius: 10px;
}

main .pokemon-card .gif{
    width: 60px;
    height: 60px;
}

main .pokemon-card .information span{
    padding: 0.3125rem;
    text-transform: uppercase;
    font-size: 1.0625rem;
}

main .pokemon-card .types {
    display: flex;
    gap: 0.9375rem;
}
  
main .pokemon-card .type{
    padding: 0.5rem;
    border-radius: 10px;
}

.grass{
    background-color: #9bcc50;
}

.poison{
    background-color: #b97fc9;
}

.fire{
    background-color: #fd7d24;
}

.water{
    background-color: #4592c4;
}

.flying{
    background-color: #3dc7ef;
}

.bug{
    background-color: #729f3f;
}

.normal{
    background-color: #83898b;
}

.electric{
    background-color: #eed535;
}

.ground{
    background-color: #ab9842;
}

.fairy{
    background-color: #fdb9e9;
}

main .description {
    max-height: 5rem;
    font-size: 14px;
    padding-right: 0.625rem;
    overflow-y: scroll; /****----- authorize vertical scroll only -----****/
}

/****----- SCROLLBAR -----****/

::-webkit-scrollbar{
    width: 12px;
}

body::-webkit-scrollbar-track {
    background: #d8e3ec;
    border-radius: 10px;
    margin-block: 0.1875rem;
}

::-webkit-scrollbar-thumb{
    background-color: #582965;
    border-radius: 10px;
    border: 3px solid #ffffff;
}

::-webkit-scrollbar-thumb:hover{
    background-color: #40144d;
}

::-webkit-scrollbar-track:horizontal{
    display: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<header>
    <a href="https://www.pokemon.com/br/pokedex/" target="_blank">
        <img src="./src/images/pokeball.png" 
        alt="pokeball" 
        class="logo">
    </a>
    <button id="theme-toggle-button">
        <img src="./src/images/sun.png" 
        alt="sun image" 
        class="toggle-button-image">
    </button>
</header>
<main>
    <ul class="pokemon-list">
        <li class="pokemon-card">
            <div class="information">
                <span>Bulbasaur</span>
                <span>#0001</span>
            </div>

            <img src="./src/images/bulbasaur.gif" alt="Bulbasaur" class="gif">

            <ul class="types">
                <li class="type grass">Grass</li>
                <li class="type poison">Poison</li>
            </ul>

            <p class="description">There is a plant seed on its back since the day this Pokémon was born. The seed grows slowly.</p>
        </li>
       <!-- More Pokemon cards go here -->
    </ul>
</main>

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

Arranging divs precisely while rotating a Bootstrap Thumbnail

I've been experimenting with creating a "css3 on hover flip" effect for bootstrap thumbnails. It works perfectly fine on simple divs (check it out here) Here's the main CSS3 code I'm using: .front{ position:absolute; transform:pers ...

Automatic popup updates when submitting a form in a Chrome extension

Looking to develop a chrome extension popup window that, when clicked, will present a form for users to input their name and college. The goal is to save this data in chrome storage and then replace the popup with a new window displaying a greeting message ...

The CSS transition timing seems to be malfunctioning as not all elements are smoothly transitioning, specifically the text within the li and anchor tags is not

I'm attempting to achieve a smooth transition effect on a navbar when hovering over it, changing the color from one to another. The navbar contains a list of words, but I am encountering an issue where during the transition, there is a quick flash (ap ...

What is the best way to save multiple HTML widgets in my HTML file using R and plot.ly?

I have recently started experimenting with plot.ly in R and I am fascinated by the ability to easily publish graphs directly in html using htmlwidgets. However, I have encountered a challenge when trying to save multiple widgets in the same html file. Curr ...

Switching the class from "untoggled" items to the selected item in React

Recently, I developed a toggle component known as Accordion. Within this component, I am iterating through an array of objects and displaying them in the following format: {object.map((o) => ( <Accordion key={o.id} title={o.question} className="i ...

Tricky problem with z-index - how to position a CSS3 triangle under the menu

Hey there, thank you for taking the time to look into my issue. I'm currently working on a menu design that I would like to resemble this example: The key feature here is creating triangular shapes on either side and positioning them beneath the men ...

Maintaining the aspect ratio of images in Bootstrap Carousel: A complete guide

Using the default carousel from Bootstrap template has been working well for me. However, I've encountered an issue where resizing the browser window distorts the image aspect ratio by squishing it horizontally. I've tried various solutions to m ...

Using the clip-path property to determine the content padding within a div

I am encountering an obstacle while attempting to insert icons into a polygon-shaped div. The problem lies with the padding, as the icons get cut off by the borders of the polygon. #container { width: 200px; height: 200px; border: 2px solid blac ...

The Django view function is failing to add new records to the database

Whenever I attempt to create a record in the FinTransDetail table as an admin, I encounter errors. This is preventing me from adding records successfully. Any assistance in resolving these issues would be greatly appreciated. Additionally, since I am unabl ...

What is the function of table widths in accommodating wider details during insertion?

What happens when a detail width is set to <td width="10"...> and something wider, like a picture that is 20 pixels wide, is placed in that detail? ...

The functionality for dragging elements is not functioning properly in JavaScript

Here is the code I used in an attempt to make a div element draggable: let div = document.querySelector('div') div.onmousedown = function() { div.addEventListener('mousemove', move, true) } window.onmouseup = function() { window. ...

Chrome Experiencing Issues with Nested Divs

Having an issue with nested divs in Chrome <div id="wrapper"> <div id="content"> </div> </div> The wrapper div acts as a bordered container, forming a box. In Safari and Firefox, the content sits inside this box consistentl ...

The Android WebView experiencing issues with the functionality of the Hamburger Menu

I'm facing an unusual issue with the Android WebView in my app. The hamburger menu on my website works perfectly fine on my mobile browser, but when I try to open it in the Android WebView, it does not fully expand to show the menu items. I have trie ...

establish a distinct row color pattern for the initial column

I am currently working on a table that has sticky columns. I am trying to create alternating row colors in the first column only. Below is the code for the table: <div class="table-responsive"> <table class="table table-bordered table-stripe ...

Conceal a specific class from being seen by another class of the same name upon clicking

I have a webpage with multiple images all sharing the same class name. When I try to hide a specific image by clicking on it, all images with that class are affected. Even though I used PHP to display the images on the webpage, I haven't been able to ...

There are times when JQuery scripts fail to function correctly

Hello there. I'm having an issue with my website - www.robbiedawson.com. Sometimes, the text in the grey footer fails to load properly, including numbers and links, making navigation impossible. This happens occasionally when refreshing the page, whet ...

Divs that are floated and only partially visible at the end

My layout consists of 6 Divs floated left to create 6 columns. The width of all these floats combined may extend beyond the window width for most users, especially with the 6th column included. Is there a way for this 6th column to be partially visible ( ...

How to Find a Specific File by Partial Name in HTML

Currently building a webpage, I need to provide a link to a log file located on the server. The catch is that the filename includes a random number at the end, but I do know the starting part of it. Here's the snippet of my code: <a href="../New_f ...

Update the class name by utilizing template literals

I'm currently in the process of mastering template literals as I have a project where I need to utilize them. However, I seem to be encountering an issue that I can't quite figure out. Here is the code that is currently working: const classes = ...

Unusual behavior encountered while attempting to reset input text using AngularJS

I'm encountering an issue with what I assumed would be a straightforward scenario. Here is the form in question: <form class="form-inline" role="form"> <div class="form-group"> <input type="text" ng-model="customerInput" size="80 ...