Tanveer Sayem / 2021-02-09
2 min read
::-webkit-scrollbar
pseudo element, which allows us to modify the look of the browser's scrollbar.::-webkit-scrollbar
property.
You can specify the width of the scrollbar and also set the scrollbar track or path by setting the background property.
::-webkit-scrollbar { width: 15px; background: #f7ece1; }
::-webkit-scrollbar-thumb { background: #cf5c36; border-radius: calc(15px/2); }
::-webkit-scrollbar-thumb
.
cursor
property with url()
value.
body { cursor:url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/9632/happy.png"), auto; }
auto
as a fallback value.cursor: url('...'), auto;
you don't have that much control. In order to customize the cursor even more and have more control over the process, we have to use javascript.Let's style this div.<div class="cursor"></div>
.cursor { position: absolute; /* so it is out of the flow */ width: 20px; height: 20px; background: white; mix-blend-mode: difference; border-radius: 50%; transform: translate(-50%,-50%); /* so it is center with the cursor pointer */ transition: 200ms ease-out; }
const cursor = document.querySelector(".cursor"); document.addEventListener("mousemove", customizeCursor); function customizeCursor(e) { cursor.style.top = e.pageY+"px"; cursor.style.left = e.pageX+"px"; }
Get emails from me about web development, tech, and early access to new articles.