scaleX()
So I understand how to use the typical css scaleX() but I am wanting to do is confusing. First I want to make a hover effect that allows me to make a button looked like it grew to the right, however I am getting it gowing from the middles and moving from the center out. I am confused how to do this
14 Replies
MDN Web Docs
transform-origin - CSS: Cascading Style Sheets | MDN
The transform-origin CSS property sets the origin for an element's transformations.
I am focusing on small components for my personal site and I seen something like this before 🙂
yeah that is not working, I have done this and it stretches out the letters too,
https://codepen.io/althepal78/pen/XWOBrBm
should I be just adding size in JS I am a confused with this
stretching the entire element including the letters is what scalex does, yeah. You can animate a right padding or width instead, that'll only scale the bounding box
you have to be a little careful with hover state changes when you exit the element, but it shouldn't happen too often
I tried using transition width as well but that did not work either when i said
transition: width 2s;
it did it instantaniouslyyou have to then also change the width in the :hover state
Okay so I need to figure out how to do that button thing I seen before I suck using psuedo elements so maybe they used that I don't know
you could change padding-right to width and then change the transition to
transition: width 1s ease-in-out;
that did not work for me with the width
oh, and you have to set a fixed width on the base class... probably better to use padding tbh
you can't animate from properties that have an
auto
value, and that's the default for widthah shoot dammit lol
so the padding thing worked perfectly for now lol
thank you 😉
glad to help 🙂
Transform-origin is a tricky one to know about but so important !