What is the best way to make CSS webkit-scrollbar compatible with HTML object tags?

I'm attempting to customize a scrollbar using CSS with the -webkit-scrollbar property. Below is the code I am using:

index.html

<html>

<head>
    <style>
        object {
            overflow: scroll;
            width: 300px;
            height: 300px;
            border: green solid;
        }

        object::-webkit-scrollbar {
            width: 20px;
        }

        object::-webkit-scrollbar-track {
            background-color: transparent;
        }

        object::-webkit-scrollbar-thumb {
            background-color: #f50000;
            border-radius: 20px;
            border: 6px solid transparent;
            background-clip: content-box;
        }

        object::-webkit-scrollbar-thumb:hover {
            background-color: #1100ff;
        }
    </style>
</head>

<body>
    <div id="_details">
        <object type="text/html" data="_details.html"></object>
    </div>
</body>

</html>

_details.html

<h1>content</h1>
<br>
<h1>content</h1>
<br>
<h1>content</h1>
<br>
<h1>content</h1>

Despite implementing the custom styles, when viewing index.html, the default scrollbar still appears.

https://i.sstatic.net/q9gkg.png

Is there a method to ensure that the object tag displays the customized scrollbar as intended? Thank you!

Answer №1

Looking to customize your scrollbar? Check out this helpful tutorial I discovered on the web: Custom Scrollbar. It's definitely worth a read!

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

Establish a secure PHP connection to MySQL database

Are there alternative methods to securely access your mysql database through php, rather than explicitly declaring your credentials in the code like this? $servername = "localhost"; $username = "user1"; $password = "pass1"; $dbname = "test-db"; // Create ...

Place the center and bottom divs within the parent div

Trying to center and fix a div at the bottom of another div has proven challenging for me. I've attempted using the following code snippet, but without success. Can anyone guide me on how to achieve this? #clockPosition { margin: auto auto 0 auto ...

Retrieving the following element

I am trying to retrieve the next sibling element of one that contains the text "Yes". Unfortunately, I can only use the text "Yes" and part of the id attribute, as the number (e.g.. 106) is not available. Due to this limitation, I am unable to directly acc ...

Tips for keeping a button selected in each row of a table

I'm confused about a simple issue. I have a table that fetches data from a JSON file, where each row represents a JSON field. In each row, I added two buttons (Like/Dislike) to assess the search quality. However, whenever I click on the like button on ...

The issue with the vertical alignment of images within a div using CSS seems to be unresolved

I have these blocks on my website that describe various features. Within each block, there is a div element containing an image, and I'm trying to vertically align the image in the middle of the div. However, my current code doesn't seem to be wo ...

Master the art of manipulating tags in Django templates using JavaScript

In my Django quiz app, there are two main components. The first part involves displaying 10 sentences with corresponding audio to help with memorization, one per page. The second part consists of asking questions based on the same set of sentences. I initi ...

HTML text not lining up with SVG text

Why is the positioning of SVG Text slightly off when compared to CSS text with the same settings? The alignment seems awkwardly offset. Any help in understanding this would be much appreciated! Even with x: 50% and the relevant text-anchor property set to ...

The CSS media query is failing to function as expected

My CSS code is as follows: @media screen and (max-width :300px) { .ui-tabs .ui-tabs-nav .ui-tabs-anchor { float: left; text-decoration: none; } } This means that I intend to modify the CSS when the screen size goes below 300px. I hav ...

Creating an element that remains in a fixed position in relation to its parent container, rather than the entire screen - here's how

Encountering an issue where, upon user scrolling down, a portion of the sidebar becomes fixed in position. However, when attempting to apply CSS for fixing the sidebar element, it ends up fixed to the entire screen instead of just within its parent contain ...

Why isn't Bootstrap validation functioning properly in my Modal?

I am attempting to implement client-side validation using bootstrap, as outlined here: https://getbootstrap.com/docs/4.0/components/forms/#custom-styles The challenge I'm facing is that my form is within a modal. When I click the submit button, nothi ...

What is the method for incorporating an infowindow into a data layer using Google Maps API?

I seem to be having trouble with incorporating an info window into a data layer containing information from a geojson link. Despite my efforts, the info window does not appear as intended in the code snippet below. To address this issue, I followed the in ...

I'm looking to center my btn button vertically and horizontally over two images using Bootstrap 5 in a responsive manner. How can I achieve this?

Any tips on how to position my btn button both vertically and horizontally in the center on top of two images? I want it to look like this: https://i.sstatic.net/Rezrd.png This is the code for my button: <a class="btn btn-primary" href=" ...

Would parallax stars be overwhelming for a webpage?

I'm a newcomer to the world of web development and I have an idea to make stars move across my website. However, I'm concerned about whether this might be too much for a simple website to handle. Is there a way to optimize the code? const canvas ...

Issue with Mobile Touch Screen Preventing Vertical Scrolling

Currently experiencing difficulties with a div element that is not allowing touch and vertical scroll on mobile devices. Although scrolling works fine with the mouse wheel or arrow keys, it does not respond to touch. Have tested this on various devices and ...

Easy Access Form

I am working on creating a straightforward login form using HTML and JavaScript. The goal is to verify the entered username and password against a set list of authorized credentials upon submission. If the input credentials are correct, I want to direct t ...

Showing an HTML table in a separate template using Django view

Currently, I have a Django view that enables users to upload a file containing data that will be graphed using a Pandas dataframe. The graph is then generated in a separate view linked within the original file upload view using an image tag, and this proce ...

Creating a Jquery slider animation: step-by-step guide

I tried implementing a code example in jQuery, but I am struggling with achieving smooth transitions in my slides. The changes are happening too abruptly for my taste. How can I create animations that occur during the transition, rather than after it? f ...

What is the best way to seamlessly switch between two different border styles?

Is it possible to smoothly transition from a dotted border to a solid one when hovering over an element? This task seems challenging with basic CSS techniques. ...

The background image is not displaying properly on the responsive.css file

Having an issue with an image not loading in my responsive.css code. I am attempting to change a background image based on different resolutions of the website. The path to the image has been checked and it is in the same file that contains HTML, CSS, and ...

When hovering over an image, CSS text will be displayed

Creating a CSS hover effect where text appears when the user hovers over a small thumbnail and a large image is displayed upon clicking. I have set up a modal for the image, but having difficulty with positioning the text. Currently, the text is located un ...