If XHTML and CSS can be object-oriented. . The sun should have risen from the north. However, everything should be viewed with OO's thoughts, and you can barely make up the numbers. In fact, someone proposed OO-style as early as a few years ago, but it was no longer found.
Then how to OO? Now everyone knows that CSS can be written introductory:
.G_G { /* xxxxxx */ }
We can look at it roughly in a prototype , or as a class , -__-b seems to be a class, and then instantiate an object in HTML, for example:
<div class=G_G>Silly yell</div>
This element will use the corresponding definition of CSS, but it is not enough to just have the corresponding class, because our page may apply this class in many places. In order to handle the private relationship well, change the code just now to:
<div id=aoao class=G_G>Silly yell</div>
In this way, the element with the ID of aoao will apply the definition of the class .G_G , and the private effect definition can be used with a selector like #aoao{} , which will not affect the public .G_G class. At the same time, the priority of the #aoao definition will be higher than that of .G_G, which is in line with the common sense that the private definition is higher than that of the public definition^^.
Since I used the unique thing ID, reusing this private definition of things becomes a problem (an ID can only appear once on one page, I don’t know who said it, it is the truth anyway). What if we want to achieve multiple privatizations? Then we must achieve polymorphism . Dig haha. Change the code again:
<div class=G_G o_O>Silly yell</div>
One is G_G and the other is o_O, but if we use .o_O{} we can also define elements, if CSS is like this:
.G_G {width:100%}.o_O {color:#123456}
The elements will all be defined, and since the definitions are not stacked, they will be applied. If the code is like this, I don’t know if it will be better understood.
<div class=layout color>Not a fool</div>
.layout{width:100%}.color{color:#123456}
Next, the packaging is implemented. Everyone should use the child selector often, change the code:
<div class=G_G><span class=bendan>Silly</span>Aoy</div>
Although both .bendan{} and .G_G .bendan{} can be defined, the latter can only be applied to elements whose class is G_G. We can simply understand .bendan{} as a global definition and .G_G .bendan{} as a local definition. This will help our modularization of XHTML and CSS. ^^The legendary encapsulation appears, and then continue.
<div id=aoao class=G_G o_O><span class=bendan>Idiot</span>Aoao</div>
Such code can produce countless changes, and you can start from scratch if you don’t understand it. ^^
In fact, these are still a long way from real object-oriented. I am just learning the title party, but I can use it to understand the application of ID and class.