Jump to content

Recommended Posts

I'll skip the boring details and get to it.

This CSS code runs an animation for an INFINITE period.

I want it to ONLY run "on mouse over" or the equivalent. I've changed the duration without issue, but cannot get it to run when desired

.obj {
  height: 90vmin;
  position: relative;
  width: 90vmin;
  
  > div {
    animation: growAndFade 3s infinite ease-out;
    /* lots of settings */
  }
  }

I've tried different variations of using

.obj :hover{
  height: 90vmin;
  position: relative;
  width: 90vmin;
  
  > div :hover{
    animation: growAndFade 3s infinite ease-out;
    /* lots of settings */
  }
  }

but seem to be missing the correct implementation.

Helpful responses, please.

Edited by phppup
Typos
Link to comment
https://forums.phpfreaks.com/topic/317371-hover-is-not-effective/
Share on other sites

.obj :hover > div :hover

That will target an .obj with a descendant-element you are hovering over which contains a DIV with another descendant-element you are hovering over. In other words, your HTML has to be something like

<A class="obj">
  <B>
    <div>
      <C>
        <!-- hovering here -->
      </C>
    </div>
  </B>
</A>

I doubt that's what you want.

:hover isn't cinnamon, so you can't sprinkle it over miscellaneous elements and expect them to taste better.

If you want the animation to play while hovering over the DIV then apply :hover directly to it alone - while also remembering that whitespace in CSS is occasionally significant.

.obj > div:hover

 

@requinix Yes, I believe I tried that initially.  It may have worked; but then it didn't.

After hours of futile efforts, I decided to post here and wait for a reply.

However, it was a Sunday afternoon and ALL my sports teams were losing. *another season of tears* LOL

My tenacity got the better of me and deeper down the rabbit hole I went.

I haven't come up with an adequate solution (and may never do so) since this was supposed to be just a 15- minute cosmetic effect.

However, I wanted to do my part as a contributor to the forum and share what I discovered:

It appears, per a variety of resources that 

Quote

@keyframes is not as easy as you might think to “restart”.

...say you set it to run once

You might think CSS provides a way to kick it off again, but ....it doesn’t. 

There seem to be several JavaScript/jQuery work-arounds or some CSS tricks to enable a smooth usefulness on every instance of an event-type.

For now, I think I've taken it as far as I am willing to go.

But the next person should be aware that events and CSS animations are not necessarily  completely compatible under the current rules that govern them.

Edited by phppup
Typos
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.