Home >Web Front-end >HTML Tutorial >How to inherit the contents of an existing class? _html/css_WEB-ITnose
c9ccee2e6ea535a969eb3f532ad9fe89
.a{
background-color:red;
}
.b{
color:red;
}
How to make b have the attributes of a?
Just do it directly.a,.b{……}
Just do it.a,.b{……}
Didn’t .a, .b also change a? Isn't it okay to just inherit without overwriting?
background-color is the background color; color is the font color
background-color is the background color; color is the font color
This is not the point, I am just giving an example, if If a color is added to the element of a, how to change the font color in b and inherit the background color of a?
You can write three styles, .a {color:red;//a unique style} .b {color:blue;//bunique style} .a,.b {background-color :red;//a b public style}
Quote from 1st Floor’s reply:
Just .a,.b{……}
.a,. Didn’t b also change a? Isn't it okay to just inherit without overwriting?
I won’t change it, you do this
<style>.a,.b{ background-color:red;}.b{ color:red;}</style>
Quote from 2nd Floor’s reply:
Quote from the 1st floor’s reply:
Just .a,.b{……}
.a, .b didn’t even change a? Isn't it okay to just inherit without overwriting?
I won’t change it, you are like this
HTML code
c9ccee2e6ea535a969eb3f532ad9fe89
.a,.b{
background-color:red;
}
.b{
color:red;
}
531ac245ce3e4fe3d50054a55f265927
In this case, b has background-color and colo at the same time...
Me I hope to use b to inherit all the attributes of a, and modify or supplement other attributes. The premise is that a is not changed, and b does not exist when a is declared, so this cannot be solved.
You can write three styles, .a {color:red;//a unique style} .b {color:blue;//bunique style} .a,.b {background-color :red;//a b public style}
I want a to be the default style and b to be a selected style, so a cannot be declared together with b, and there cannot be a common style.
080b747a20f9163200dd0a7d304ba388
.a {
background-color:#CCC;
}
.b {
color:# F00;
}
531ac245ce3e4fe3d50054a55f265927
76b7c8ffae66bba790de8245016bdce8
adasd
16b28748ea4df4d9c2150843fecfba68
Yours, Is this what you mean?
080b747a20f9163200dd0a7d304ba388
.a {
background-color:#CCC;
}
.b {
color:# F00;
}
531ac245ce3e4fe3d50054a55f265927
76b7c8ffae66bba790de8245016bdce8
adasd
16b28748ea4df4d9c2150843fecfba68
Yours, Is this what you mean?
That’s it, that’s how I use it now, but I hope that I can use the function of a b with only b, but I don’t want to write the code twice
There seems to be no solution? If you can’t help it, just post it and share the hard work with everyone