"- I can’t get the first class css to be applied to the others"
This is a bit confusing. If you want an element to be stylized "with both classes", just define the two classes in the element:
.button-default{
background-color: #49bf9d;
border: 2px solid #49bf9d;
color: white;
padding: .75em 1.5em;
border-radius: 5px;
font-size: .9em;
}
.button-default-empty{
background-color: white;
border: 2px solid #efefef;
color: inherit;
}
<input class="button-default" type="submit" value="button-default">
<input class="button-default-empty" type="submit" value="button-default-empty">
<input class="button-default button-default-empty" type="submit" value="button-default + button-default-empty">
"- I cannot change the property to:Hover of these classes"
Just add the :hover
right in class:
.button-default-empty{
background-color: white;
border: 2px solid #efefef;
color: inherit;
}
.button-default-empty:hover{
color:#49bf9d;
background-color: #49bf9d;
}
<input class="button-default-empty" type="submit" value="button-default-empty">
Notice that at no time did I inform the tag element. Therefore, any element you define with these classes will be stylized with these properties.
Notice that statement:
.button-default-empty a:hover {
color:#49bf9d;
background-color: #49bf9d;
}
You define that any element a
who is the child of any class element button-default-empty
(no matter the level) is stylized in the event :hover
. See working:
.button-default-empty a:hover {
color:#49bf9d;
background-color: #49bf9d;
}
<div class="button-default-empty">
<a href="#">Um link filho da classe button-default-empty</a>
<div>
<div>
<a href="">Um outro link, digamos que, filho da classe button-default-empty</a>
</div>
</div>
</div>
Recommended reading: CSS selectors
You need to specify your problem better, the style is being applied correctly. Your
hover
is not working because the correct would be:.button-default-empty:hover
.– fernandosavio
I’m actually doing a font-end course and in this course the teacher created these 2 classes, the difference in his second class porjeto inherited all the definitions of the first just by changing what was added in the second class, I tried to do it the same way but as you can see it didn’t work
– Reignomo