Transform CSS into React styling syntax

I am having trouble converting CSS code from an HTML template for text input into a React project. I am not a CSS expert, and I am encountering some syntax errors. Can someone help me fix this issue? I have included the CSS code, app.js file, and error image below for reference.

Here is the CSS code:

.slide-up {
      display: inline-block;
      width: 215px;
      padding: 10px 0 10px 15px;
      font-family: "Open Sans", sans;
      font-weight: 400;
      color: #377D6A;
      background: #efefef;
      border: 0;
      border-radius: 3px;
      outline: 0;
      text-indent: 80px; 
      transition: all .3s ease-in-out;
      
  
      &::-webkit-input-placeholder {
        color: #efefef;
        text-indent: 0;
        font-weight: 300;
      }
  
      +label {
        display: inline-block;
        position: absolute;
        transform: translateX(0);
        top: 0;
        left: 0;
        padding: 10px 15px;
        text-shadow: 0 1px 0 rgba(19, 74, 70, .4);
        transition: all .3s ease-in-out;
        border-top-left-radius: 3px;
        border-bottom-left-radius: 3px;
        overflow: hidden;

        &:before,
        &:after {
          content: "";
          position: absolute;
          right: 0;
          left: 0;
          z-index: -1;
          transition: all .3s ease-in-out;
        }

        &:before {
          // Skinny bit here
          top: 6px;
          left: 5px;
          right: 5px;
          bottom: 6px;
          background: #377D6A; // change this to #134A46
        }

        &:after {
          top: 0;
          bottom: 0;
          background: #377D6A;
        }
      }
    }
  
    span:nth-child(1) .slide-up {
      text-indent: 105px;
    }
  
    span:nth-child(3) .slide-up {
      text-indent: 125px;
    }
  
    span:nth-child(1) .slide-up:focus,
    span:nth-child(1) .slide-up:active,
    span:nth-child(3) .slide-up:focus,
    span:nth-child(3) .slide-up:active {
      text-indent: 0;
    }
  
    .slide-up:focus,
    .slide-up:active {
      color: #377D6A;
      text-indent: 0;
      background: #fff;

      &::-webkit-input-placeholder {
        color: #aaa;
      }

      +label {
        transform: translateY(-100%);

        &:before {
          border-radius: 5px;
        }

        &:after {
          transform: translateY(100%);
        }
      }
    }

This is my React app.js code:

<span>
                <input
                  classname="slide-up"
                  id="card"
                  type="text"
                  placeholder="Fund me!"
                />
                <label for="card">Credit Card</label>
              </span>

Syntax Error Image Here: https://i.sstatic.net/YJyf5.png

Answer №1

It seems like using a .scss file instead of a .css file would be more appropriate, as css lacks support for nesting and other features.

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

When deploying a Node.js Express API using Docker, the headers are not being sent

After creating a Node.js Express API, I implemented the /login endpoint for users to authenticate and receive an Authorization Token: @Post('/login') @UseBefore(validationMiddleware(LoginUserDto, 'body')) async logIn(@Res() res: R ...

Creating TypeScript types for enums can make your code more robust and ensure that you are using

I need to create an interface based on the values of an enum for a React use-case. The enum contains key value pairs that are used as form IDs. When the value of an input element is changed in an event listener, I want to set the state using this.setState( ...

The dimensions of Material UI cards vary between desktop and mobile devices

While developing a single page application, I encountered an issue with the display on mobile devices. The design looks great on my laptop screen, but it appears distorted on mobile. Currently, I am using Material UI with ReactJS for this project. Here is ...

An issue has been encountered with the convertFromHTML function in React Draft Wysiwyg

I am currently utilizing React Draft Wysiwyg to construct a robust text editor. After successfully obtaining the HTML version below, I store it in a database. const [editorState, setEditorState] = useState(() => EditorState.createWithContent(Con ...

When using TypeScript with custom components as children in React, the `type` returned by React.Children is a string representing the function

It might sound a bit odd, or maybe I'm completely off track here. While going through some articles and React documentation on getting children and identifying specific child components using React.Component.map(), I ran into an issue with my custom c ...

Is there a way to update the image source of three images using a button in ReactJS?

Is there a way to switch the source of 3 images with a button in reactjs? This should trigger a function that changes the theme from dark to light mode. const switchTheme = () => { const newTheme = theme === "light" ? "dark" : ...

Utilize Bootstrap to align elements side by side for a sleek and organized

i have a collection of images that I fetched from an API, and I created a component to display them. The issue I'm facing is that I want to arrange these 50 images in rows of 3, with each row having a title below the images. However, I'm not fami ...

Issue with Material-UI Select occurring due to race condition that mistakenly identifies value as being out of range during conditional rendering used to create MenuItems

I am currently utilizing Material-UI to develop Select components for my dashboard. The options within the Select are dynamically generated using conditional rendering. Using map, I generate MenuItems based on a predefined list of options retrieved from a ...

The usage of CSS pseudo elements with the position absolute property

To allow for the opacity of an image to be changed without affecting the parent container's opacity, I added the image as a pseudo-element. The position of the pseudo-element is set to absolute and relative to the parent to position it inside the p ...

What could be causing the malfunction of my token rotation feature in nextAuth?

I am developing a web application that involves working with an external API alongside my team member. We are making API requests using Next.js. I have implemented nextAuth for authentication, but I am facing issues with token rotation. After successful lo ...

Looking to alter the CSS of an ID element when hovering over a link on your website?

Irrespective of the positioning of the links in the html, a simple hover effect can trigger changes like switching images or altering backgrounds anywhere on the website. The ideal solution would involve a straightforward method without the need for Javas ...

The transitionend event fails to trigger if there is no active transition taking place

Take a look at this: http://jsfiddle.net/jqs4yy0p/ JS $('div').addClass('switch').on('transitionend', function(e){ alert('end'); }); CSS div { background-color: red; /*transition: background-colo ...

Numerous mistakes detected in the TypeScript code

I've implemented the following class within an ASP.NET Core React application: import * as React from 'react'; interface MyInputProps { inputType: string; id: string; className: string; parentFunctio ...

React-router-dom: When you click on a Link, the route is continuously appended to the URL Link

Finally, after multiple attempts, I have successfully incorporated basic nested-routing using React-router-dom. Here is the straightforward structure of the project: https://i.stack.imgur.com/fifsc.png Below are the important files: App.js imp ...

What is the best way to apply a background color to text seamlessly? (Using HTML5 and CSS3)

<!-- 6장 연습문제 4 --> <html lang = "ko"> <head> <meta charset = "UTF-8"> <style> img{margin-left: auto; margin-right: auto; display: block;} .hyper{ text-decoration-line: ...

Conceal a different CSS class if a certain CSS class is present on the page

I am currently working on organizing my page to distinguish between purchased and unsold products. For the items that have been bought, I am using the CSS class "winning_bid" within a div element. My goal is to hide another div with the class "price" if th ...

Challenge with CSS3 designstyling

After creating a tag, I noticed that there is a white background after the arrow on the right side. .tags { list-style: none; margin: 0; overflow: hidden; padding: 0; } http://jsfiddle.net/eR8Ye/5/ Is there a way to eliminate the white backgro ...

React component fails to load and display during page loading

I am struggling with implementing a Loading component on my page that displays media fetched from an API. The Loading component works fine when displaying a single item, but it fails to show up when loading multiple items. How can I modify my code to creat ...

Is Ant Design's modal maskClosable feature malfunctioning?

I have implemented ANT Design's modal in a separate component as shown below: import React from "react"; import { Modal, Button } from "antd"; class CustomModal extends React.Component { constructor(props) { super(props); this.state = ...

Change the CSS property to override the text-overflow with ellipsis

In my specific scenario, I need to override the default ellipsis behavior that adds '...' to text when using 'text-overflow: ellipsis', and instead use two stars **. Is there a way to achieve this using only Pure CSS? It is important t ...