-1
I have a code I want to apply scale
in all the <a>
and <button>
, as shown in the example below:
body{
background: #000;
}
#lista, #lista li{
margin: 0;
padding: 0;
list-style: none;
font-size: 20px;
}
#lista li{
width: 25%;
max-width: 100px;
min-width: 70px;
display: inline-block;
margin: 20px 10px 10px 10px;
vertical-align: top;
}
#lista li a{
color: #fff;
}
#lista li{
-webkit-transition: color .1s ease;
transition: color .1s ease;
}
#lista li img{
width: 100%;
max-width: 100px;
max-height: 100px;
margin-bottom: 10px;
opacity: .9;
-webkit-transition: -webkit-transform 1s ease;
transition: transform opacity 2s ease;
}
#lista li:hover img{
opacity: 1;
-webkit-transform: scale(1.1);
transform: scale(1.1);
-webkit-transition: -webkit-transform .1s ease;
transition: transform opacity .1s ease;
}
a{
text-decoration: none;
color: #e8747d;
display: inline-block;
}
a:hover{
color: #FFFED3;
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
button, a{
-webkit-transition: -webkit-transform .1s ease;
transition: transform .1s ease;
cursor: pointer;
}
button:hover{
-webkit-transform: scale(1.18);
transform: scale(1.18);
}
<ul id="lista">
<li>
<a href="#">
<img src="https://upload.wikimedia.org/wikipedia/en/thumb/4/47/Dracula_One_Sheet_Style_F.jpg/220px-Dracula_One_Sheet_Style_F.jpg">
Título
</a>
</li>
</ul>
<div style="background: gray;">
<a href="#">Link qualquer</a>
<button>Botão qualquer</button>
</div>
Works perfectly, the problem is that I do not want the text "Title" that accompanies the image within the link on <li>
suffer the scale
(static), just the image.
I’ve tried to use :not(#lista li a)
in some places but without success. I think the way is to use this :not
somewhere, but I couldn’t do.
How could I fix this?
But because the title has to stay inside the tag
a
??– LeAndrade
It’s because if I click on it I want to go to the same place as clicking on the image.
– Sam
Yes, but I find it easier to click on an image than on a non-text?
– LeAndrade
But I want the title to also be a link, not just the image.
– Sam
I get it, it’s in this structure there’s not going to be like that then, as Hugo said, the child element is getting the same properties as the parent element, and there’s no way to remove them.
– LeAndrade
Remove the
a:hover{
doesn’t solve the problem ? Or this one has to work but not when there’s an image inside too ?– Isac
@Isac O
a:hover
is to catch all the<a>
... But I’ve already managed to settle by putting a class on<a>
that I don’t want to be affected.– Sam
Yeah, that’s exactly what I was going to suggest is that it’s pretty simple and it solves because it only hits those it wants
– Isac
@Isac Want to post the answer? Now, what I didn’t understand was this: with class it works, but I don’t understand why
:not(#lista li a)
does not work. If you want to post an answer explaining why this selector does not work would be welcome.– Sam
As far as I know the problem has to do with hierarchy. The proof of this is that to exchange for something simple with the
not
works. Try doinga:not(.desligado):hover { ...
and add the offline class to the one that doesn’t want the effect.– Isac
@That’s what I did.
– Sam
Judging by this answer https://stackoverflow.com/a/7084147/6087092 it doesn’t seem possible, at least for now, that is, using only css.
– Isac