Home Web Front-end CSS Tutorial How is CSS scroll bar style compatible with IE8 and Chrome browsers?

How is CSS scroll bar style compatible with IE8 and Chrome browsers?

Jul 21, 2017 pm 02:31 PM
chrome firefox webkit

CSS Tutorial

Recently when I was improving my website, I accidentally discovered that when clicking on different columns in the navigation, the text on the web page would flash (drift) left and right. After careful inspection and consideration , and found that the problem lies in the scroll bar on the right side of the browser, that is: when the height of the web page content is less than one screen; there is no scroll bar on the right side, and the calculated screen width at this time should be the width of the entire monitor (assumed to be 1440 ), and when the height of the web page content exceeds one screen, the calculated screen width should be 1440-scroll bar width. For this reason, when you set margin: 0 auto and switch between short screen and long screen, This will cause a slight jittering sensation on the web page.

Based on the above problem, I was thinking about how to solve it, but after constant attempts, I finally came to the conclusion that this problem basically cannot be completely solved, because it also depends on the performance of different browsers. Take the three browsers IE8, Sogou, and Chrome for testing. As we all know, the latest version of Sogou browser has two modes: compatible (IE core) and high-speed (WebKit core). In high-speed mode, Sogou’s performance is already comparable to Chrome. It's close (or I haven't seen the difference yet), but the strange thing is that in compatibility mode, although the IE kernel is called, it behaves differently from pure IE8. For example, for short web pages (not enough for one screen) ), although Sogou will not appear scroll bars, it will reserve a blank width on the right side of the screen for scroll bars. That is to say, for Sogou compatibility mode, regardless of short screen or long screen, the calculated width will always be 1440-scroll bar width. However, this is not the case with IE8. The reserved alternate width of the scroll bar will not appear when the screen is short, and the width will be automatically added when the screen is long. This is the same as Chrome's performance, which is incredible! Currently, there are so many types of browsers on the market that it is impossible to make them compatible with all of them, so I plan to give up making adjustments in this area.

Although the problem was not solved, the scroll bar was finally beautified a little, and it was basically consistent with the color of the page. The CSS style of the scroll bar has always been very good in IE, but Chrome has turned a blind eye. After consulting a lot of information on the Internet and wandering around in major forums, they basically said that Chrome's scroll bar cannot be implemented with CSS. In the end, It's easy to use JS or pictures to simulate, etc., but in the end there are articles that provide compatible codes. Surprisingly, the width of Chrome's scroll bar can be set through code. I tried it, and it feels good. Record it (including comments, the color code can be modified according to your own needs):
For IE8:

html,body {
scrollbar-face-color:#FB4446; /*滚动条3D表面(ThreedFace)的颜色*/ 
scrollbar-highlight-color:#fff; /*滚动条3D界面的亮边(ThreedHighlight)颜色*/ 
scrollbar-shadow-color:#eeeeee; /*滚动条3D界面的暗边(ThreedShadow)颜色*/ 
scrollbar-3dlight-color:#eeeeee; /*滚动条亮边框颜色*/ 
scrollbar-arrow-color:#000; /*滚动条方向箭头的颜色 */ 
scrollbar-track-color:#fff; /*滚动条的拖动区域(TrackBar)颜色*/
scrollbar-darkshadow-color:#fff; /*滚动条暗边框(ThreedDarkShadow)颜色*/ }
Copy after login

For Chrome:

/*---滚动条默认显示样式--*/  
::-webkit-scrollbar-thumb{  
   background-color:#FB4446;  
   height:50px;  
   outline-offset:-2px;  
   outline:2px solid #fff;  
   -webkit-border-radius:4px;  
   border: 2px solid #fff;  
}  
/*---鼠标点击滚动条显示样式--*/  
::-webkit-scrollbar-thumb:hover{  
   background-color:#F01360;  
   height:50px;  
   -webkit-border-radius:4px;  
}  
/*---滚动条大小--*/  
::-webkit-scrollbar{  
   width:8px;  
   height:8px;  
}  
/*---滚动框背景样式--*/  
::-webkit-scrollbar-track-piece{  
   background-color:#fff;  
   -webkit-border-radius:0;  
}
Copy after login

The above is the detailed content of How is CSS scroll bar style compatible with IE8 and Chrome browsers?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is Updater.exe in Windows 11/10? Is this the Chrome process? What is Updater.exe in Windows 11/10? Is this the Chrome process? Mar 21, 2024 pm 05:36 PM

Every application you run on Windows has a component program to update it. So if you are using Google Chrome or Google Earth, it will run a GoogleUpdate.exe application, check if an update is available, and then update it based on the settings. However, if you no longer see it and instead see a process updater.exe in the Task Manager of Windows 11/10, there is a reason for this. What is Updater.exe in Windows 11/10? Google has rolled out updates for all its apps like Google Earth, Google Drive, Chrome, etc. This update brings

What file is crdownload? What file is crdownload? Mar 08, 2023 am 11:38 AM

crdownload is a chrome browser download cache file, which is a file that has not been downloaded; crdownload file is a temporary file format used to store files downloaded from the hard disk. It can help users protect file integrity when downloading files and avoid being damaged. Unexpected interruption or stoppage. CRDownload files can also be used to back up files, allowing users to save temporary copies of files; if an unexpected error occurs during downloading, CRDownload files can be used to restore downloaded files.

What to do if chrome cannot load plugins What to do if chrome cannot load plugins Nov 06, 2023 pm 02:22 PM

Chrome's inability to load plug-ins can be solved by checking whether the plug-in is installed correctly, disabling and enabling the plug-in, clearing the plug-in cache, updating the browser and plug-ins, checking the network connection, and trying to load the plug-in in incognito mode. The solution is as follows: 1. Check whether the plug-in has been installed correctly and reinstall it; 2. Disable and enable the plug-in, click the Disable button, and then click the Enable button again; 3. Clear the plug-in cache, select Advanced Options > Clear Browsing Data, check cache images and files and clear all cookies, click Clear Data.

What is the Chrome plug-in extension installation directory? What is the Chrome plug-in extension installation directory? Mar 08, 2024 am 08:55 AM

What is the Chrome plug-in extension installation directory? Under normal circumstances, the default installation directory of Chrome plug-in extensions is as follows: 1. The default installation directory location of chrome plug-ins in windowsxp: C:\DocumentsandSettings\username\LocalSettings\ApplicationData\Google\Chrome\UserData\Default\Extensions2. chrome in windows7 The default installation directory location of the plug-in: C:\Users\username\AppData\Local\Google\Chrome\User

How to solve the problem that Google Chrome cannot open web pages How to solve the problem that Google Chrome cannot open web pages Jan 04, 2024 pm 10:18 PM

What should I do if the Google Chrome web page cannot be opened? Many friends like to use Google Chrome. Of course, some friends find that they cannot open web pages normally or the web pages open very slowly during use. So what should you do if you encounter this situation? Let’s take a look at the solution to the problem that Google Chrome web pages cannot be opened with the editor. Solution to the problem that the Google Chrome webpage cannot be opened. Method 1. In order to help players who have not passed the level yet, let us learn about the specific methods of solving the puzzle. First, right-click the network icon in the lower right corner and select "Network and Internet Settings." 2. Click "Ethernet" and then click "Change Adapter Options". 3. Click the "Properties" button. 4. Double-click to open i

How to remove Firefox Snap in Ubuntu Linux? How to remove Firefox Snap in Ubuntu Linux? Feb 21, 2024 pm 07:00 PM

To remove FirefoxSnap in Ubuntu Linux, you can follow these steps: Open a terminal and log in to your Ubuntu system as administrator. Run the following command to uninstall FirefoxSnap: sudosnapremovefirefox You will be prompted for your administrator password. Enter your password and press Enter to confirm. Wait for command execution to complete. Once completed, FirefoxSnap will be completely removed. Note that this will remove versions of Firefox installed via the Snap package manager. If you installed another version of Firefox through other means (such as the APT package manager), you will not be affected. Go through the above steps

what does chrome mean what does chrome mean Aug 07, 2023 pm 01:18 PM

Chrome means browser, a web browser developed by Google. It was first released in 2008 and quickly became one of the most popular browsers in the world. Its name comes from the browser's interface design because of its iconic The feature is the tab bar at the top of the window, and the appearance of this tab bar is very similar to chrome metal.

How to search for text across all tabs in Chrome and Edge How to search for text across all tabs in Chrome and Edge Feb 19, 2024 am 11:30 AM

This tutorial shows you how to find specific text or phrases on all open tabs in Chrome or Edge on Windows. Is there a way to do a text search on all open tabs in Chrome? Yes, you can use a free external web extension in Chrome to perform text searches on all open tabs without having to switch tabs manually. Some extensions like TabSearch and Ctrl-FPlus can help you achieve this easily. How to search text across all tabs in Google Chrome? Ctrl-FPlus is a free extension that makes it easy for users to search for a specific word, phrase or text across all tabs of their browser window. This expansion

See all articles