1
I’m having a problem I’m editing a h2
with css and within that h2
has a span
but wanted to apply the style in h2
but I don’t want style to apply to my span
I’m using the selector :not(span)
but it doesn’t work follow my code:
html
<div class="text-center box-product band-product">
<h2>Quero<br>anunciar meu<br><span>produto</span></h2>
<a href="#" title="Saiba mais">Saiba mais <i class="fas fa-arrow-right"></i></a>
</div>
SCSS:
.box-product{
background-color: $light-gray;
h2:not(span){
line-height: 30px;
@include gradient-orange(#f97c16, #feb226);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
span{
color: $gray;
font-weight: normal;
font-family: "good_vibes", sans-serif;
font-size: 2em;
text-transform: capitalize;
}
}
}
notice that the color I’m applying to h2
is applying in my span tbm do not want it as I can resolve follow the image
then the problem of doing this is that besides repeating the code realize that in span has an orange borada of H2 well subted more to see so I believe that :not() would help me 100% understand that I am using wrong the attribute with scss has some way to do-that it works ?
– Felipe Henrique
@Kirito I’ll take a test and tell you
– hugocsl
beauty thank you so much :)
– Felipe Henrique
@Kirito did some tests here I can even disregard the color in span, but when you use the background there is no way not to make it go behind the child too, unless the child has its own background. It’s like when you put opacity on the div and everything inside it also gets opacity... At the moment besides repeating the classes, including putting a background-image: linear-gradient(Gray, Gray); in span to remove the orange outline I can’t find another solution
– hugocsl
Understood friend thank you very much if you can update the answer with the test you did by removing the orange borada thank you
– Felipe Henrique
@Kirito already edits, but actually only repeated the classes in span but changing the color to
gray
maybe it’s not the perfect solution, but I couldn’t think of anything better, mainly because the span is inside H1 and is "inheriting" some styles and bg.– hugocsl
@Kirito at the end of my reply I made another Edit, and includes a practical example and a few words on how to use not(), I think it can give you a light when it comes to nesting with SCSS
– hugocsl