CSS Animations are effective in CodePen, but unfortunately, they do not function properly once integrated into an ASP.Net project

I created a unique design on codepen with a background animation, which functions properly there. However, when I integrate it into my ASP.Net Core project, the animation doesn't work as expected. The file references seem correct because the background color displays, but the animation does not. Initially, I suspected it was a browser issue in Chrome, but even Firefox does not render the animation. The only thing remaining untested is whether it works on regular IIS instead of IIS Express.

Code:

CSS:

body{
    margin:0;
    padding:0;
    background:0 0;
}

.parallaxBackground {
    min-height:100%;
    min-width:100%;
    background-attachment: fixed;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
}

.colorcycle {
    min-height: 100%;
    min-width: 100%;
    display: inline-block;
    text-align: center;
    background: linear-gradient(271deg, #e7ff26, #2ecc00, #ff3b00, #2a9fff);
    background-size: 800% 800%;
    -webkit-animation: AnimationName 10s ease infinite;
    -moz-animation: AnimationName 10s ease infinite;
    -o-animation: AnimationName 10s ease infinite;
    animation: AnimationName 10s ease infinite;

    -webkit-keyframes AnimationName {
        0% {
            background-position: 92% 0%
        }

        50% {
            background-position: 9% 100%
        }

        100% {
            background-position: 92% 0%
        }
    }

    @-moz-keyframes AnimationName {
        0% {
            background-position: 92% 0%
        }

        50% {
            background-position: 9% 100%
        }

        100% {
            background-position: 92% 0%
        }
    }

    @-o-keyframes AnimationName {
        0% {
            background-position: 92% 0%
        }

        50% {
            background-position: 9% 100%
        }

        100% {
            background-position: 92% 0%
        }
    }

    @keyframes AnimationName {
        0% {
            background-position: 92% 0%
        }

        50% {
            background-position: 9% 100%
        }

        100% {
            background-position: 92% 0%
        }
    }
}

HTML:

<body>
    <!--Parallax Landing Section-->
    <div class="parallaxBackground">
        <div class="colorcycle">testing testing testing </div>
    </div>
    <!--Parallax Landing Section-->
</body>

Edit: To troubleshoot, I isolated the code by creating a basic folder on the desktop and testing the HTML and CSS independently. No other dependencies like JS or Bootstrap were included. Unfortunately, I encountered the same issue. It seems to be related to how the files are processed. One possibility could be that Codepen uses .scss files for CSS, which may impact the animation. I will explore this further for a solution.

Answer №1

After some trial and error, I finally cracked the code. While SASS allows for nested selectors, this functionality doesn't carry over to standard CSS. Removing the nested selectors from the class did the trick and now everything is working smoothly.

.colorcycle {
    min-height: 100%;
    min-width: 100%;
    display: inline-block;
    text-align: center;
    background: linear-gradient(271deg, #e7ff26, #2ecc00, #ff3b00, #2a9fff);
    background-size: 800% 800%;
    -webkit-animation: AnimationName 10s ease infinite;
    -moz-animation: AnimationName 10s ease infinite;
    -o-animation: AnimationName 10s ease infinite;
    animation: AnimationName 10s ease infinite;
}

@-webkit-keyframes AnimationName {
    0% {
        background-position: 92% 0%
    }
    50% {
        background-position: 9% 100%
    }
    100% {
        background-position: 92% 0%
    }
}

@-moz-keyframes AnimationName {
    0% {
        background-position: 92% 0%
    }
    50% {
        background-position: 9% 100%
    }
    100% {
        background-position: 92% 0%
    }
}

@-o-keyframes AnimationName {
    0% {
        background-position: 92% 0%
    }
    50% {
        background-position: 9% 100%
    }
    100% {
        background-position: 92% 0%
    }
}

@keyframes AnimationName {
    0% {
        background-position: 92% 0%
    }
    50% {
        background-position: 9% 100%
    }
    100% {
        background-position: 92% 0%
    }
}

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

Encountering an issue with re-rendering components in REACT when using the setState hook

Is there a way to efficiently change the inline style property of multiple items based on their position info stored in a useState hook? I want to update the CSS value of all items except for the one that was clicked on. I tried using setState to achieve t ...

Guide to creating an uncomplicated quiz using PHP

My goal is to create a quiz with 15 questions. Every time a user lands on the page, they will see a random selection of 5 questions. Each question will have 4 multiple choice answers, with one being correct. The marks allocated for each question are 20, 15 ...

The HTML output from converting Tiny MCE text content is not rendering properly on the React app's front-end

I'm currently working on a blog project using React and Material UI. In order to enable users to add posts, I've integrated a TinyMCE rich text editor onto the page. The issue arises when trying to display a specific blog post, as the content app ...

Processing .dat files using JavaScript

Currently, I am attempting to utilize JavaScript to upload a file named example.dat. Initially, I believed that the correct approach would be using fileReader; however, it appears that this method is unable to process this specific format. The objective i ...

Stop the form from refreshing upon submission using an Ajax call in AngularJS

Currently, I am in the process of developing a search form that requires two inputs: Job title and Location. These keywords are used to gather data from various websites. However, upon submitting the form, the page refreshes itself. To prevent this, I have ...

"Angular File Upload Made Easy with Drag-and-Drop Functionality and Cleverly Positioned

Encountering an issue with Angular File upload in conjunction with relatively positioned elements. The drop target is set to 100% width and height, absolutely positioned. While dragging a file over any non-relatively positioned element, the overlay functio ...

Using jQuery to dynamically change the CSS color based on the background-color of a checkbox label

When a checkbox is selected, the function below runs to change the text color to white or black based on the darkness of the background color. However, the third checkbox should trigger this change to white but currently does not. function isDark(color) { ...

I have a website hosted on Heroku and I am looking to add a blog feature to it. I initially experimented with Butter CMS, but I found it to be too pricey for my budget. Any suggestions on

I currently have a website running on Heroku with React on the front end and Node.Js on the back end. I want to incorporate a blog into the site, but after exploring ButterCMS, I found the pricing starting at $49 to be too steep for my budget. My goal is ...

Tips on maximizing the file size limit of the fileupload control in asp.net

I am trying to determine the file size limit for my file upload control. Below is the HTML code snippet: <input id="uplTheFile" style="WIDTH: 318px; HEIGHT: 22px" type="file" size="80" name="uplTheFile" runat="server"> I have checked the code but ...

Guide to attaching a mouse click event listener to a child element within a Polymer custom component

I'm currently facing an issue where I am attempting to attach a click listener to one of the buttons within a custom element during the "created" life cycle callback (even attempted using the "ready" callback with the same outcome). Unfortunately, I ...

Creating HTML code that is optimized for mobile devices

My front end design is based on the CSS stylesheet from W3Schools.com, which includes a class property called "w3-rightbar" for adding a thick right border. However, I encountered an issue where I needed to hide this "w3-rightbar" specifically on mobile vi ...

What measures can be taken to restrict users from inputting decimal values?

My website includes an order page where users can input quantities for various items. While some items allow for decimal quantities, others do not. What is the most effective method to restrict users from entering decimal quantities? (Besides using an ale ...

Unable to display image on HTML page transmitted via socket in Java

After successfully loading my simple HTML in Chrome and seeing it display correctly, I encountered a troubling issue when trying to pass it through a Java socket. Despite only passing bytes through the socket, the image always appears broken. The perplexin ...

How can I make a DIV occupy the entire vertical space of the page?

I am working on a Google Maps application that takes up the majority of the screen. However, I need to reserve a strip at the top for a menu bar. How can I ensure that the map div fills the remaining vertical space without being pushed past the bottom of ...

Looking for solutions to issues with Style errors and Visibility problems?

< table border="1" cellpadding="0" cellspacing="0" width="100%"> < tr> < td>1< /td> < td>1< /td> < td>1< /td> < td>1< /td> < td>1< /td> ...

What is the best way to trigger a function exclusively upon clicking a particular element?

My goal is to enable the user to interact with the model by positioning cubes in space upon clicking the "Cubes Mode" button. I currently have a script from the three.js website that achieves this, but I want it to only run when the mentioned button is cli ...

What is the best way to position the section and footer to the left side of the sidenav?

I am relatively new to the world of html and css, trying my hand at constructing html layouts. I have encountered a bit of trouble in aligning the footer and section to the left of the nav bar. No matter what percentage widths I use, they always end up ove ...

Is there a way to position the search bar on a new line within the navigation bar when the screen size is at its maximum width for mobile

I have a search bar on my navigation bar, but I am looking to move it to the next line within a maximum width if the screen display is extra small (xs) or for mobile devices. Below is the code snippet: <nav class="navbar navbar-expand-md fixed-top ...

Struggling with aligning images in the center of a square container

Currently revamping my photography website and working on a simple slider to showcase some of my photos. Struggling with aligning the images in divs with padding all around while keeping them centered. I want to replicate the look of my photos on Instagram ...

Is the jSON data featured at the top with DIV / Table Headers positioned at the bottom?

I'm really struggling with this issue. I've tried a few different things but nothing seems to work. Any suggestions on how to tackle this problem? Here's a link to a screenshot of the error I'm encountering... <div class="contain ...