Embedding @keyframes within @media queries

I need to resolve an issue involving curly brackets. However, all opening brackets have a corresponding pair. There is an error on line 212

Expected RBRACE at line 212, col 2. @-webkit-keyframes move {

Oddly enough, when I test the code separately before and after line 212, no errors are visible.

@media all and (min-width:  1px){
.main-pointing-slider .box .dot-4{
    bottom: -2px;
    left: 128px;
    top: auto;
    right: auto;
    bottom: -2px;
    left: calc(50% - 3px);
    position: absolute;
    -webkit-animation-name: dotShow;
    -webkit-animation-duration: 0.5s;
    -webkit-animation-delay: 2s;
    -webkit-animation-timing-function: linear;
    -moz-animation-name: dotShow;
    -moz-animation-duration: 0.5s;
    -moz-animation-delay: 2s;
    -moz-animation-timing-function: linear;
    animation-name: dotShow;
    animation-duration: 0.5s;
    animation-delay: 2s;
    animation-timing-function: linear;
    -webkit-animation-fill-mode: forwards;
    -moz-animation-fill-mode: forwards;
    animation-fill-mode: forwards;
    background: linear-gradient(to bottom, #dcd4cb 0%, #f3c886 100%)
}
... 
@-webkit-keyframes move {
    0% {
        -webkit-transform: scaleX(0.1);
        -moz-transform: scaleX(0.1);
        -ms-transform: scaleX(0.1);
        transform: scaleX(0.1);
        opacity: 1
    }
    100% {
        -webkit-transform: scaleX(1);
        -moz-transform: scaleX(1);
        -ms-transform: scaleX(1);
        transform: scaleX(1);
        opacity: 1
    }

}

}

This syntax error is preventing the validator from identifying a closing bracket in the @media section.

Answer №1

As per the guidelines outlined by the W3C:

It is deemed as invalid to include at-rules within @media in CSS2.1.

Reference: www.w3.org - Media types

This scenario will not function as expected:

@media (max-width: 768px) {

   @media (max-width: 450px) {

   }

}

Nor will this one:

@media (max-width: 768px) {

   @-webkit-keyframes animation {

   }

}

It is recommended that keyframe animations be defined outside of any media types and then applied within the appropriate media queries when required.

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

Ways to duplicate a letter in HTML?

How can a character be printed repeatedly within a table cell using only HTML or HTML and CSS (excluding HTML5)? *(limiting to only HTML or a combination of HTML and CSS) ** The goal is to print the character "." across the entire length of the cell, wit ...

The bootstrap modal is appearing correctly, but the content within it is not displaying properly

I've been working on a website and added a modal for signup. However, when the user clicks on the signup button, the modal appears but the content inside it is not clickable. Can someone please help me with this issue? Here is the code snippet I am us ...

What's the best way to update the menu element colors as I scroll down the page?

I am looking to update the color scheme of menu elements as the page scrolls using the provided template. I tried a few methods, but they lack dynamism. How can I make it more dynamic? $(document).ready(function(){ //scroll animation $('.navigati ...

The speed at which Laravel loads local CSS and JS resources is notably sluggish

Experiencing slow loading times for local resources in my Laravel project has been a major issue. The files are unusually small and the cdn is much faster in comparison. Is there a way to resolve this problem? https://i.stack.imgur.com/y5gWF.jpg ...

Deactivating one div's class upon clicking on another div

Below is the HTML code snippet: <div class="container"> <ul class="navbar"> <li class="nb-link"><a>Home</a></li> <li class="dropdown"> <a>CBSE</a> <ul class="dropdown-menu"&g ...

Content that is partially concealed when scrolling through div elements

I have been searching high and low for similar questions, but to no avail. So, I am laying out my problem here in the hopes that you could guide me on what I might be doing wrong and how to rectify it. The scenario I am trying to achieve is having two divs ...

How can I stop MUI Button from automatically becoming fullWidth?

One of the challenges I encountered was styling a Button component from MUI: export const ButtonStyle = styled((props) => <Button {...props} />)(({ theme }) => ({ marginTop: 8, marginBottom: 8, width: 'auto', borderRad ...

Obtaining the width of a scrollbar using JavaScript in the most recent version of Chrome

Looking for a way to determine the width of the scrollbar using JavaScript for CSS purposes. I attempted the following: document.documentElement.style.setProperty('--scrollbar-width', (document.offsetWidth - document.clientWidth) + "px" ...

Showing a hidden div after an unsuccessful AJAX call

Encountering an issue with displaying a div notification using the code snippet below: $.ajax({ url: url, cache: false, async: false, success: function (data) { response = jQuery.parseJSON(data); }, error: functi ...

Ways to eliminate the excess margin of ng-container from the webpage

When controlling two mat tabs with a statement, I encountered an interesting issue. Both mat-tab elements contain a card-list and are controlled with a statement in ng-container. Strangely, on the first tab, the card has a slight margin from the top when I ...

Changing the display property causes ordered lists to shift towards the left

// Ensure the list is displayed when checked and hidden when unchecked. function toggleList(event) { let ol = document.getElementById('list'); if (event.currentTarget.checked) { ol.style.display = 'initial'; } else { ol.s ...

What are the steps for adding a JSON file to a GitHub repository?

Could someone lend a hand with my GitHub issue? I recently uploaded my website to a GitHub repository. The problem I'm facing is that I have a JSON file containing translations that are being processed in JavaScript locally, and everything works fine ...

Can you choose the stylesheet.cssRule[] based on a class name or ID?

Currently, I am able to modify the font size by accessing the first style sheet using the following code: document.styleSheets[0].cssRules[0].style.fontSize = "16"; Here is the CSS snippet: h1 {font-size: 12} .someClass {} As the CSS file ...

Creating a Bootstrap layout with a fixed top navigation bar, sidebar, and footer

I have a webpage with four components. Top Navigation Sidebar Footer Main content My goal is to have the Top Navigation fixed at the top, the footer fixed at the bottom, and the sidebar to stick to the left with full height. To achieve this layout, I h ...

I can't figure out what's not working with my full-width video cover

I'm having trouble creating a full-width video cover for the header of a website. Can someone help me troubleshoot what I'm doing wrong? Here is a snippet of my code: <section id="home"> <video poster="assets/img/home-bg.png" a ...

Unable to view the image in browsers other than Internet Explorer

On a webpage, there is a feature where clicking on the "Add More" link should display an input box and a "Delete" button image. Surprisingly, this functionality works perfectly on IE browsers, but not on Mozilla or Chrome. In non-IE browsers, only the text ...

Encountering issues with CSS Modules in Next.JS app while using app/about/layout.tsx

Currently, I am delving into the world of Next.js and encountering some challenges with locally scoped CSS modules. In my project, I have an about directory which contains a layout component. Strangely, the styles applied to the layout component are not b ...

Some characters are not compatible with the CSS writing-mode feature

There seems to be an issue with the CSS writing mode not applying correctly to the symbol '№'. Here is an example: <html> <head></head> <body> <p style="writing-mode: vertical-lr;"> Номер № ...

Leveraging Bootstrap grid system within AngularJS elements

I am currently working on wrapping grid element divs into Angular components in order to streamline the input process and establish a standard: <bootstrap-row> <bootstrap-input-text col=6 ng-model="$ctrl.model" label="hey!"& ...

What is the best way to update auto margins after resizing an element with Javascript?

I'm having an issue with a DIV on my webpage that is centered using margin-left and margin-right set to auto. When I try to resize the DIV, it no longer stays centered on the screen. <div id="content" style="margin-left:auto;margin-right:auto;widt ...