CSS3 features modify (custom) default browser scroll bar, css3 scroll bar

Source: Internet
Author: User

CSS3 features modify (custom) default browser scroll bar, css3 scroll bar

When we are working on the front-end, we may encounter some requirements. We need to rewrite the scroll bar style of the default browser. What has it done? It doesn't bring the user experience. It's just a good look! The implementation principle is actually using pseudo elements. The pseudo elements of webkit are very powerful. You can define the scroll bar as a page element, and combine some CSS3 attributes, such as rounded corners, gradient, and rgba. The most common pseudo elements are the elements we are most familiar with before and after (: before/: after) [pseudo classes (: hover/: link )]. Here is a Demo. Let's take a look...

I. HTML

<div class="banner_box"></div>

Ii. CSS

<Style>. banner_box {width: 100%; height: 2000px;}/* scroll bar style * // * overall part of the scroll bar */:-webkit-scrollbar {width: 8px ;} /* Small scroll bar */:-webkit-scrollbar-thumb {background-color: rgba (0, 0, 0, 0.6);-webkit-border-radius: 5px; /* Safari and Chrome */-moz-border-radius: 5px;/* Firefox */-o-border-radius: 5px;/* Opera */border-radius: 5px;}/* buttons at both ends of the rolling track */:-webkit-scrollbar-button {-webkit-box-shadow: inset 0 0 6px rgba (, 85, 1 ); /* border-radius: 10px; */background-color: #555;}/* rolling track shadow */:: -webkit-scrollbar-track {-webkit-box-shadow: inset 0 0 6px rgba (255,255,255, 1);/* border-radius: 10px; */background-color: # F5F5F5 ;}</style>

 

Iii. Results

 

Summary: This CSS feature is not compatible with IE and Firefox, but can be seen by others. There is also a way to rewrite the scroll bar through div.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.