1.Xhtml scroll bar color problem
In the original html, we can define the scroll bar of the entire page like this:
body{
scrollbar -3dlight-color:#D4D0C8; /*- Outer left-*/
scrollbar-highlight-color:#fff; /*- Second from left-*/
scrollbar-face- color:#E4E4E4; /*-face-*/
scrollbar-arrow-color:#666; /*-arrow-*/
scrollbar-shadow-color:#808080; / *- Second from the right-*/
scrollbar-darkshadow-color:#D7DCE0; /*- First from the right-*/
scrollbar-base-color:#D7DCE0; /*- Base color- */
scrollbar-track-color:#;/*- Slider-*/
}
But the same code cannot be used under xhtml It worked. I believe many good friends have encountered the same problem.
So how can I apply the scroll bar style under xhtml? Look at the following code:
html{
scrollbar-3dlight-color:#D4D0C8; /*- outermost left-*/
scrollbar-highlight-color:#fff ; /*- Second from left-*/
scrollbar-face-color:#E4E4E4; /*- Face-*/
scrollbar-arrow-color:#666; /*- Arrow -*/
scrollbar-shadow-color:#808080; /*- Second from the right-*/
scrollbar-darkshadow-color:#D7DCE0; /*- First from the right-*/
scrollbar-base-color:#D7DCE0; /*- base color-*/
scrollbar-track-color:#;/*- slide track-*/
}
The only difference between this code and the previous paragraph is that among the elements defined by css, one is body and the other is html. Let's test it again and change the "body" of the html page to "html" to test it and find that the effect can still be achieved. So why?
Let’s take a look at the picture below:
This is the most basic dom tree structure of HTML.
Let’s take a look at the definitions of html and xhtml:
HTML (Hyper Text Markup Language, Hyper Text Markup Language), Hyper Text Markup Language is widely used on the Internet Above. HTML describes how the text base is rendered and how hyperlinks connect to other pages.
XHTML (Extensible Hypertext Markup Language, Extensible Hypertext Markup Language) is a markup language whose expression is similar to HTML, but the syntax is more strict. In terms of inheritance relationship, HTML is an application based on SGML and is very flexible, while XHTML is based on XML, which is a subset of SGML. XHTML 1.0 became a W3C recommendation on January 26, 2000.
Literally, xhtml has one more x than html, so this x is actually xml. Why do we need to add xml in it? In fact, the most fundamental reason is to make html more structured and standardized (because html is really bad).
OK, let’s go back and look at the structure tree above. What we define in html is body. Because html is not very standard, this can take effect, but in xhtml this will not work. I look at the picture. Obviously, the body tag itself is not the root element, only html is the root element, and the scroll bar of the page also belongs to the root element, so this is why our definition of body has no effect, because what we define is only a sub-element. OK, we know the principle, let’s do an experiment. If we change the definition of “body” or “xhtml” to “*”:
*{
scrollbar-3dlight-color:#D4D0C8; /*- Outer left-*/
scrollbar-highlight-color:#fff; /*- Second from left-*/
scrollbar-face-color:#E4E4E4; /*- Face-*/
scrollbar-arrow-color:#666; /*- Arrow-*/
scrollbar-shadow-color:#808080; /*- Second from the right-*/
scrollbar-darkshadow-color:#D7DCE0; /*- Right one-*/
scrollbar-base-color:#D7DCE0; /*- Base color-*/
scrollbar-track-color:#;/*- Slider-*/
}
is passed in both html and xhtml, because * is to define any tag on the page, of course it also includes " html" tag.
(ps: In fact, it is not so much the difference between html and xhtml as it is the difference between whether there is XHTML 1.0 transitional doctype, but if you remove the XHTML 1.0 transitional doctype from the page, then this page will not have a doctype , the default display mode is html4.01, but you have to change the XHTML 1.0 transitional doctype to HTML 4.01 doctype. The same page definition body will not have any effect, although the standard of this page is html 4.01)
2 , The problem of horizontal scroll bars on frame pages under xhtml
When using IE6 to browse xhtml pages with frames, the horizontal and vertical scroll bars will appear together by default. This is a bug in IE6, and it is in Firefox. Normally, the reason is due to a flaw in its interpretation of the XHTML 1.0 transitional doctype.
There are generally 3 solutions to this bug,
Method 1:
Code:
html { overflow-y: scroll; }
Principle: Force the display of IE's vertical scroll bar and ignore the horizontal scroll bar.
Advantages: Completely solves this problem, allowing you to maintain the complete XHTML doctype.
Disadvantages: Vertical scroll bars will appear even when the page does not require vertical scroll bars.
Method 2:
Code:
html { overflow-x: hidden; overflow-y: auto; }
Principle: Hide horizontal scrolling, and vertical scrolling is adaptive according to the content.
Advantages: Visually solves this problem. Vertical scrollbar is not forced to appear when not necessary.
Disadvantages: It only hides the horizontal scroll bar. If the page really needs the horizontal scroll bar, the content outside the screen will not be visible because the user cannot scroll horizontally.
Method 3:
Code:
body { margin-right: -15px; margin-bottom: -15px; }
Principle: This will Add a negative value to the margin horizontally and vertically. After IE adds this exact value, it will remove the illusion of the need for scroll bars.
Advantages: This problem is solved visually, and vertical scrolling is adaptive according to the content.
Disadvantages: Since the 15px margin is "artificially created", the filled screen area cannot be used.
The above is the detailed content of About scroll bars in HTML/removing scroll bars. For more information, please follow other related articles on the PHP Chinese website!