Create a CSS skeleton screen with invisible borders that do not reflect any visible outlines

  • I wanted to create a skeleton screen using CSS
  • For reference, I used the link below: https://css-tricks.com/building-skeleton-screens-css-custom-properties/
  • However, when implementing it in my React app, I encountered an issue.
  • Although I can see the HTML div code, the CSS changes are not visible.
  • I tried debugging by adding borders, but the problem persists.
  • Could someone provide guidance on how to resolve this issue?
  • Below is my code snippet and sandbox for reference:

Link to Code Not Working: https://stackblitz.com/edit/react-kjhuv7?file=card.scss

.card {
  width: 280px; 
  border: red;
  height: var(--card-height);

  &:empty::after {
    content:"";
    display:block;
    width: 100%;
    height: 100%;
    border-radius:6px solid black;
    box-shadow: 0 10px 45px rgba(0,0,0, .1);
    background-color:  brown;

    background-image:
      linear-gradient(
        90deg, 
        rgba(lightgrey, 0) 0, 
        rgba(lightgrey, .8) 50%, 
        rgba(lightgrey, 0) 100%
      ),                          //animation blur
      var(--title-skeleton),      //title
      var(--desc-line-skeleton),  //desc1
      var(--desc-line-skeleton),  //desc2
      var(--avatar-skeleton),     //avatar
      var(--footer-skeleton),     //footer bar
      var(--card-skeleton)        //card
    ;

    background-size:
      var(--blur-size),
      var(--title-width) var(--title-height),
      var(--desc-line-1-width) var(--desc-line-height),
      var(--desc-line-2-width) var(--desc-line-height),
      var(--avatar-size) var(--avatar-size),
      100% var(--footer-height),
      100% 100%
    ;

    background-position:
      -150% 0,                      //animation
      var(--title-position),        //title
      var(--desc-line-1-position),  //desc1
      var(--desc-line-2-position),  //desc2
      var(--avatar-position),       //avatar
      var(--footer-position),       //footer bar
      0 0                           //card
    ;

    background-repeat: no-repeat;
    animation: loading 1.5s infinite;
    background-color: black;
  }
}

@keyframes loading {
  to {
    background-position:
      350% 0,        
      var(--title-position),  
      var(--desc-line-1-position),
      var(--desc-line-2-position),
      var(--avatar-position),
      var(--footer-position),
      0 0
    ;
        background-color:  yellow;

  }
}

Answer №1

In the realm of Javascript, the term class is considered to be reserved, making it off-limits within JSX code. This is because using it might lead to confusion with the class keyword in Javascript. JSX code, although resembling Javascript, actually gets compiled later on for better interpretation by the runtime.

Therefore, opt for className instead of class when assigning a CSS class to an element:

<div class="card"> card data</div>

should now be like this

<div className="card"> card data</div>

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

Guide to dynamically inserting an audio file into a div with jQuery

I am looking to dynamically insert an audio file. Below are the declared tags: <div> <audio id="myaudio"> </audio> </div> Now, I am trying to add the source dynamically. Can anyone help me with how to add it to the div or audi ...

Struggling with identifying errors in the Javascript code for my assignment

My code is giving me trouble and I could really use some assistance You can find my code in this GitHub folder: link. To see the project in action, visit this page on GitHub Pages: link. The task involves iterating over an array of names and printing eit ...

How come I am unable to assign a value to my dropdown element following an AJAX request?

I am retrieving an array from session storage to act as a "saved" file. The data in the array is used to prepopulate input fields so users can continue where they left off. While all inputs populate correctly, dropdown elements do not. To retrieve options ...

Steps to activate a button within an element

I'm currently utilizing Cypress for my testing needs: https://i.sstatic.net/zUL4B.png Within my display, I have 3 classes that share the same name. Additionally, all the Ben logos within this class also share the same class name. My goal is to clic ...

Make TypeScript parameter optional if it is not supplied

I am working with an interface that defines scenes and their parameters: export interface IScene<R extends string> { path: R; params?: SceneParams; } The SceneParams interface looks like this: export interface SceneParams { [key: string]: s ...

Resetting an HTML form automatically after submitting with AJAX

My HTML form has a simple structure, including reset and submit buttons that are activated through an AJAX call. Whenever I click the reset button, the form reverts back to its initial state, which works perfectly for me. However, after submitting the fo ...

Achieve full implementation of ng-repeat within an angular directive

Can you explain how the custom angular directive 'myscroll' is able to detect and interact with the ng-repeat elements that are dynamically created in the code snippet below? <myscroll> <div ng-repeat="item in items">{{item}}< ...

Side Menu with Fixed Position Created with Tailwind CSS

Can anyone help me create a social media sidebar that stays fixed on the bottom right side of the screen, regardless of its size? Currently, the sidebar moves when I scroll down, but I want it to remain in place. How can I achieve this fixed positioning? ...

A small space underneath the <a> element nested within a <li> tag within a navigation bar

As a new programmer, I am currently working on creating a navbar. However, I have encountered an issue where there are small gaps underneath the user when my cursor hovers over it. There is a white gap under the user element. I expect that the hover back ...

Modifying the initialValues prop on a Formik Form does not reflect changes in the input values

Utilizing a Formik form with forward refs in the following manner Form.js import React from "react"; import FormikWithRef from "./FormikWithRef"; const Form = ({ formRef, children, initialValues, validationSchema, onSubmit }) ...

Implementing a pull-to-refresh feature in React Native using Redux

I need to implement pull to refresh functionality, but I'm unsure of what to call from _Refresh(). My actions, constants, and reducers are stored on another page. How can I trigger the API again? Thank you in advance for your assistance. class Homewo ...

JavaScript for Verifying Phone Numbers

After extensive research and tutorials, I am still unable to figure out what is going wrong with my work. I have a button that looks like this: Despite Stack Overflow causing some trouble for me, please ignore the missing class as it is there. This is no ...

Activating scrolling through Javascript

A friend of mine created a web page to help me learn some JavaScript. He designed a feature where the content in each div becomes visible as soon as the user scrolls past it. However, I noticed that the content appears too late for my liking. I would like ...

Verify the ng-if condition for a specific value and display an alternative option if the condition is not

When obtaining a response from the server in JSON format (containing color.mix and color.pure), it is passed directly to the template. In this template, I need to display a value if it exists or show another value if it does not. <span ng-if="color.mix ...

React.js - jQuery method fails to function

The application utilizes node.js and react.js, specifically the use of react-async. Within a react component, there is a click handler that needs to retrieve the class names - specifically minus_decrement and inline_block. To achieve this, jQuery was integ ...

A guide on utilizing bootstrap tooltip feature to display information when hovering over an image

I have a jQuery function that dynamically creates an image and li element on the page. My goal is to implement a bootstrap tooltip so that when the mouse hovers over the image, additional details about it will be displayed in a separate tooltip similar t ...

I encountered an issue while attempting to install dependencies listed in the package.json file using the npm install command

npm encountered an error with code 1 while trying to install a package at path C:\Users\HP\Desktop\workings\alx-files_manager\node_modules\sharp. The installation command failed due to issues with the sharp plugin and its ...

What is the best way to include small text below an input-group?

I'm attempting to insert a small text below an input group, but it's not working the same way as it does with form-groups. In this example, I want the help text to be positioned under the input rather than beside it. Here's what I mean by i ...

How do I retrieve the return value of another function in React?

I am working on a function called HandleCitiesArray where I need to access the myCitiesArray. To achieve this, I want to utilize the useSelector hook from Redux. Specifically, I aim to remove an object from initialState.myCities array. How can I go about ...

Error: Headers already sent, please check the sequence of your Expressjs, Firebase, React, and Redux code

After spending hours researching, I stumbled upon an interesting issue. I am working on a small app using ExpressJS, Firebase, and React. My goal is to call the Firebase Database through the Express Backend and also make post requests to store data in the ...