The sass animation stopped functioning properly once a transition-timing function was incorporated

I attempted to create a box with a border and a small div inside of it. I wanted the small div to animate when hovering over the box, but the animation did not start as expected. I even tried removing the hover effect, but the animation still did not work.

Here is what I have tried:

<div class="row mb-4">
      <div class="col col__animation">
        <div id="object"></div>
      </div>
    </div>

SCSS:

.col__animation{  
    display: flex;
    border-radius: 1rem !important;
    border: 1px solid #284876;
    height: 200px !important;
    align-items: center;
    
    #object {
        width: 40px;
        height: 50px;
        background: blueviolet;
        margin-top: 2px;
        margin-bottom: 1px;
        margin-right: 3px;
    }
    
    &:hover{
        #object{
            transition: transform 1000ms;
            transition-timing-function: ease-in-out;
        }
    }

}

I have been experimenting with various animation effects such as moving the box to the right and back to its initial position, among others.

Answer №1

Here is the code snippet that should do the trick:

.col__animation {
  display: flex;
  border-radius: 1rem !important;
  border: 1px solid #284876;
  height: 200px !important;
  align-items: center;
}

.col__animation #object {
  width: 40px;
  height: 50px;
  background: blueviolet;
  margin-top: 2px;
  margin-bottom: 1px;
  margin-right: 3px;
  animation: mymove 3s infinite;
}

@keyframes mymove {
  0% {
    margin-left: 0px;
  }

  50% {
    margin-left: calc(100% - 40px);
  }

  100% {
    margin-left: 0px;
  }
}

Check out Codepen for live demo!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What steps should I take in order to shift my navbar links over to the right side of the navigation bar

When creating my portfolio, I wanted to align my name on the left side of the navbar and have the list items appear on the right. Despite using the float:right property in my CSS, the list items did not move to the right as intended. Below is the code snip ...

Jquery Query: Is it possible to incorporate variables into CSS properties?

I manage a website that supports multiple languages, and I want to adjust the position of my container based on the selected language. To achieve this, I attempted the following code: prop = lang == 'ar' ? 'right' : 'left'; $ ...

"Can you guide me on positioning an image logo before text by utilizing the content attribute within the style tag

I am new to coding and experimenting with HTML. I want to display an image before the text "hello html" but for some reason, it is not working. Here is the code I have tried: <head> <style> .img::before { content: url("img/smartphone.png"); ...

"Combining Three.js for dynamic rendering with Bootstrap grids for responsive

Experimenting with three.js and bootstrap, I encountered an issue where the cube appears flattened when using bootstrap grids: https://i.sstatic.net/M2G4D.jpg Oddly, resizing the window fixes the problem: https://i.sstatic.net/E09BL.jpg Attempts to rem ...

Having difficulty altering the font in the WordPress tinymce editor

I've been attempting to update the font in the WordPress tinymce editor, but I'm running into issues. First, I created a tinymce-custom-editor.css file with the following code: @import url(https://fonts.googleapis.com/css?family=Open+Sans:400,7 ...

Using :before and :after in CSS, three dots can be created in a horizontal line

I am currently trying to display three horizontal dots on my webpage. I have created a demonstration on jsfiddle. span { position: relative; background-color: blue; border-radius: 5px; font-size: 0; margin-left: 20px; padding: 5px; ...

The function .classList.remove() is effective when applied to one element, but fails to work on a different element

I am facing an issue where only one element is getting affected when trying to remove classes from multiple elements if certain email input requirements are met. Can someone help me understand why this is happening? Here is the code snippet: const emailI ...

Troubleshooting border-left and td alignment problems in an HTML email displayed in Outlook 2013

Currently, I am facing a frustrating challenge while working on an HTML email signature. It seems to display perfectly in all email clients except for Outlook 2007, 2010, and 2013. The specific issue I'm encountering is with the alignment of the secon ...

Is the Pure CSS hide/show technique using radio buttons causing a challenge with parent and descendant elements?

Exploring a CSS Show/Hide functionality using radio buttons is my current challenge. The snippet below demonstrates how smoothly it works. .refusal, .acceptance { display: none; } input#refusal:checked~.refusal { display: block; } input#acceptanc ...

Issue with Bootstrap 'align-content-around' not functioning as expected

The align-content: space-around property does not seem to be working in this scenario. What is the solution? How can columns 3 and 4 be aligned to the bottom? .row { background: #f8f9fa; } .col { border: solid 1px red; padding: 10px; height: 20 ...

How can I change the cursor of a button to a pointer in Bootstrap 4 when the button is not disabled?

I'm working with a bootstrap button <button class="btn btn-primary">Login</button> My goal is to change the cursor to a pointer (hand) on this button when it's not disabled, instead of the default arrow. The disabled property of th ...

Basic HTML code that displays either one or two columns based on the width of the screen

My monitoring website displays dynamic rrd graphs in png format with fixed dimensions. I am looking to adjust the layout based on browser window size - showing the graphs in 1 column if the width is below a certain threshold, and in 2 columns if it exceed ...

Guide to utilizing CSS3 selectors to target each alternating element

Here's the current structure of the code: <section> <article> <p>Title</p> <p>Content</p> </article> <article> <p>Title</p> <p>Content</ ...

The span's presence causes the neighboring span to shift downwards

HTML <span class="symbol">$</span> <span class="value">400</span> This code snippet displays the symbols "$" and "400" at the same level in the document. However, if we introduce some styling using CSS: .symbol { font-size: 2e ...

Unusual activity discovered when using JavaScript addClass and removeClass methods

While experimenting with animate.css, I created a custom Javascript function to initiate animation events. This simple function, triggered by an onClick event on a button, is only three (or four) lines long, but encounters a perplexing error. The anim fu ...

How can you declare variables in CSS using LESS?

I am facing a challenge where I need to dynamically change the branding color and other styling variables on the portal based on certain conditions at runtime. I have successfully implemented this functionality using CSS with the code snippet provided be ...

What is causing the issue with this pseudo class selector not functioning properly?

I've been experimenting with the :after selector to create an inside-border effect in every div I hover over. However, I'm facing an issue where the ":after" pseudo-class doesn't seem to work. Any insights on why this selector isn't fun ...

How can you determine if a DIV element is within view in HTML (without being overflowed)?

Is there a way to determine if a DIV is within its container and therefore visible? In this scenario, the active button (highlighted) can be seen because it is contained within the boundaries: However, in this case: The active button cannot be viewed as ...

Is there a way to position the button on the right side rather than the center using a negative right Y value?

I'm looking for something that: Has a button on the right side, not just beside the input. The current setup involves using an unattractive width: 138%, which doesn't consistently work across different browsers and devices. The button ends up a ...

Enlarge an element to the extent of filling the list item

I am facing a challenge in expanding the a elements within this jsfiddle to fully occupy the li element. The use of display:block does not seem to be effective since I am utilizing a table for spacing. What steps can I take to achieve this while ensuring ...