Utilize CSS/SCSS to apply dynamic styles in Vue components

Currently, I am utilizing animate.css in my project. One of the components, a v-flex element, is structured as follows:

<v-flex md3 sm6 xs12 v-for="(d, index) in data" :key="organization.id"
             class="animated fadeInLeft" :style="{ 'animation-delay': index/8 + 's' 
       }">
<v-card>
-----
</v-card>
</v-flex>

In this setup, the animated fadeInLeft CSS classes are being applied to all cards by default. To create a delay effect on each card based on its position, I have implemented the use of animation-delay, which works as intended except for Safari browser. For Safari compatibility, I need to include -webkit-animation-delay. Though adding multiple styles in v-style and recalculating the value is an option, it does not produce aesthetically pleasing results. Are there any jQuery functions or SCSS mixins that can dynamically assign style values to elements without compromising on design integrity?

Answer №1

If you assign a unique identifier to each Card, you can achieve this using the following SCSS function:

$totalCards: 6;
@for $i from 1 through $totalCards {
    #card-#{$i} {
        animation-delay: #{$i * 0.5}s;
        -webkit-animation-delay: #{$i * 0.5}s;
    }
}

SCSS output:

#card-1 {
  animation-delay: 0.5s;
  -webkit-animation-delay: 0.5s;
}

#card-2 {
  animation-delay: 1s;
  -webkit-animation-delay: 1s;
}

#card-3 {
  animation-delay: 1.5s;
  -webkit-animation-delay: 1.5s;
}

#card-4 {
  animation-delay: 2s;
  -webkit-animation-delay: 2s;
}

#card-5 {
  animation-delay: 2.5s;
  -webkit-animation-delay: 2.5s;
}

#card-6 {
  animation-delay: 3s;
  -webkit-animation-delay: 3s;
}

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

Does CSS in the current IE9 beta allow for text shadows to be implemented?

Text shadows look great in Firefox and Chrome. For example, I have a basic website for streaming videos. Unfortunately, there are no shadows in IE9 for me. This is my CSS code: p { color: #000; text-shadow: 0px 1px 1px #fff; padding-bottom: 1em; } ...

Aligning UL LI elements vertically for multi-line textORHow to vertically

I am dealing with a ul list that contains both single and multi-line li text. The issue is that the second line of the multi-line text starts at a different indentation than the first line. I need a simple solution to resolve this problem that works seaml ...

Four unique classes will each be styled differently using pseudo selectors

Consider using this specific markup - it cannot be altered (Even though it would be simpler to add more classes or IDs). There will always be a maximum of six class "test" elements on the page, so the code can be written without certainty of their surroun ...

Unique background image tailor-made for each radio button

Looking to create radio buttons with buttonset that have unique icon backgrounds for each button. Open to options other than buttonset if available, but assuming it needs to be used. Key requirements: No radio button icon Rollover effect Icon background ...

What is the best way to retrieve all the listed TV and film ratings in descending order? Using Django

Our Goal I aim to organize movies based on their star ratings and filter out those with ratings lower than a specified threshold. 2. Retrieve the IDs of Movies and TV shows mentioned in the view, fetch the data and score through URLs one by one. 3. Presen ...

Make sure to wait for the complete loading of all content in the AJAX response before showing it on

I am currently working on a search function that sends a json request to the server for results every time a character is entered. Although this part is functioning correctly, I am trying to figure out how to add a loading class to .search-load > .conta ...

What is the best way to input JSON objects into an autocomplete feature?

When I tried to implement an autocomplete feature using jQuery and Ajax, I encountered an issue. While the objects were successfully requested and appeared in the preview tab under "network," I struggled with rendering them into the HTML... $(document).r ...

Execute JavaScript AJAX Request On Page Load

I am facing an issue with creating an onload event in which an AJAX function needs to be called and passed a value. The challenge lies in the fact that I have both my header and footer split into sections via PHP, therefore I cannot place it on the body ta ...

The use of non-breaking space symbol ( ) does not function properly in Weblogic 14

After upgrading from Weblogic 12 to Weblogic 14 Server, I encountered a change in behavior. Previous Status Everything was functioning properly before the update. When requesting an html page with &nbsp; whitespaces, the server would include these spa ...

understanding nested json with backbone

I'm currently developing my first app using backbone and I am looking for the best approach to parse a JSON object with multiple levels. Here's a simple example of the JSON structure: { "hotels":[ { "hotel" : [ { "n ...

How can one module in Nuxt mutate the Vuex state of another module?

After trying multiple solutions from the portal without success, I am reaching out here for alternative suggestions. In my Nuxtjs application folder store\modules, I have two modules: ModuleA and ModuleB. I need to access the state from ModuleA in Mo ...

Customize Bootstrap layout on the fly

I have encountered a slight dilemma. I am attempting to implement something similar to the following: <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> <script src="https://ajax.googleapis.com ...

Demonstrate the utilization of JQuery to unveil a secondary menu

I need assistance in implementing a sub-menu that automatically appears within 2 seconds after the page loads, instead of requiring user interaction. I am currently utilizing JQuery, which serves as the core framework for my website. It is crucial for this ...

Successfully Determining User Identity with Ajax Authentication

Currently, I am facing a security issue with my login page that uses an Ajax request for user authentication. The password entered by the user is sent as plain text in the form data of the Ajax request, making it vulnerable to interception by sniffing tool ...

Updating the background image with Jquery is resulting in a distracting flicker effect

Here is a snippet of the script I'm using to create a slider that changes the background image for each image object in a specified time cycle. #Sliderimg - height set to 500px, $("#Sliderimg").css({ "background-image": "url(../Images/" + SliderIma ...

The breadth of the container

I am facing challenges in determining the setup of the content width with a fixed side panel. I want the side panel to maintain a set width regardless of the screen size, while the rest of the window accommodates the navbar, content, and footer. I have bee ...

Wrapping flex items inside a table in IE11: A guide

I am facing an issue with the code (codepen here) that works in normal browsers but not in IE11... I need the cards to be wrapped within the displayed window vertically, without any horizontal scrolling. https://i.sstatic.net/PnxR9.png .table {display: ...

Easily adjust the width of divs within a parent container using CSS for a seamless and uniform

I am designing a webpage where I have set the container width to 100% to cover the entire screen width. Inside this container, I have multiple DIVs arranged in a grid structure with a float: left property and no fixed width, just a margin of 10px. Is ther ...

What is the best way to define relative paths for content like CSS files?

Whenever I link to a file, I always find myself having to include the entire absolute path like this <link rel="stylesheet" type="text/css" href="F:/XmppOld/XAMPP2/htdocs/MAIN_SITE_LAYOUT/css/stylemainpage.css" /> I want to simplify it to ...

When scrolling down, the popup window shifts its position

I have implemented a popup window which displays a list on hover. It works perfectly on the default page, but when I scroll down, the popup also moves with the scrollbar. Below is the HTML code that creates the hidden popup list initially and shows it on ...