having difficulty in configuring the precise CSS for the login page

I am struggling to replicate a specific login page design. The design I want can be found at this link: https://i.sstatic.net/smEWd.jpg

However, my current implementation looks like this: https://i.sstatic.net/DvpEL.jpg

import React, { useState } from "react";
import Header from "./Header";
// import { Button, FormGroup, input, label } from "react-bootstrap";
import "./Login.css";

export default function Login1(props) {
//   const [email, setEmail] = useState("");
//   const [password, setPassword] = useState("");
    const [user, setUser] = useState({email : "", password : ""})

  function validateForm() {
    return user.email.length > 0 && user.password.length > 0;
  }

  function handleSubmit(event) {
    event.preventDefault();
    
  }

  return (
    
    <div className="Login">
        <Header person = {user}/>
      <form className="modal-content animate" onSubmit={handleSubmit}>
      <div><h3 align='center'>Login</h3>
       </div>
       <div className="Container">
          
          <input type="text"
            autoFocus
            placeholder="Username"
            value={user.email}
            onChange={e => setUser({...user,email : e.target.value})}
          />
            {/* {console.log(user)} */}
        
          <br/>
          <input type="password" placeholder="Password"
            value={user.password} 
            onChange={e => setUser({...user,password : e.target.value})}
            
          />
        <br/><button disabled={!validateForm()}type="submit">
          Login
        </button> 
        </div>
        <div id="footer">
        <button className="submit1" disabled="true" type="submit">
          Sign up
        </button>
        <br/><button className ="submit1" disabled="true" type="submit">
          Forgot Password?
        </button>
        </div>
      </form>
    </div>
  );
}
@media all and (min-width: 480px) {
  .Login {
    padding: 120px 0;
  }

  .Login form {
    margin: 0 auto;
    max-width: 480px;
  }
  
  // Rest of CSS code removed for brevity

  form {
    border: 3px solid #f0f0f0;
  }

}

I have experimented with adjusting the width and CSS properties in the code but haven't been able to achieve the desired login page design. Can someone provide assistance with this?

The provided code snippet was written using React. The HTML code is present in login.js along with the attached CSS file.

Answer №1

I made a modification by adding a className to the Login button called submit0

<button className="submit0" disabled={!validateForm()} type="submit">
    Login
</button>

You had given the id of footer but in the .css file, you were using .footer, so it should be changed to #footer.

I included CSS for setting a background image.

.Login {
    background-image: url(https://i1.wp.com/512pixels.net/downloads/macos-wallpapers-thumbs/10-12--thumb.jpg?zoom=1.25&w=640);
    background-repeat: no-repeat;
    background-size: cover;
    padding: 120px 0;
}

Added opacity to the Login Form.

.Login form {
    margin: 0 auto;
    max-width: 480px;
    opacity: 0.9;
}

Removed border from the .modal-content.

.modal-content {
    background-color: #fefefe;
    margin: 10px auto; /* 15% from the top and centered */
    /* border: 1px solid #888; */
    border-radius: 15px;
    width: 120%; /* Could be more or less, depending on screen size */
}

Adjusted the Footer CSS -

#footer {
/*background-color: #9fa9a3;
margin: 10px auto; /* 15% from the top and centered */
    /* border: 1px solid #888;
    border-radius: 15px; */
    /*width: 100%;  Could be more or less, depending on screen size */
    background-color: #666;
    margin-top: 10px;
    border-bottom-left-radius: 11px;
    border-bottom-right-radius: 11px;
}

For input fields and the login button, I added left and right margins, border-radius, and adjusted the width to 90%

input[type="text"],
input[type="password"] {
    width: 90%;
    padding: 10px 10px;
    margin: 8px 24px;
    display: inline-block;
    border: 1px solid #ccc;
    box-sizing: border-box;
    border-radius: 11px;
}

Styling for buttons -

.submit0 {
    width: 90%;
    margin: 8px 24px;
    border-radius: 11px;
}

.submit1 {
    background-color: inherit;
}

Link to CodeSandbox

Answer №2

If you want to test if the CSS file classes are being read correctly, try adding some custom inline styling to the page and see if it works as expected. If everything looks good, then you should check the CSS class in the main file and use inspect element to verify if Login.css is loading on the page.

For tips on using inline styling, check out this link: https://codeburst.io/4-four-ways-to-style-react-components-ac6f323da822

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

Is there an alternative solution to resolving this issue with OTP verification?

Working on a verification system where users are redirected to verify their account with an OTP code after signing up. However, I encountered an issue where the code doesn't seem to work as expected and no error messages are being displayed. <?php ...

behind the scenes of a disappearing bootstrap modal

Greetings everyone! Currently, I am deep into the process of identifying and resolving a pesky bug that has been impacting my work. The project in question involves developing a module for an open-source platform built on Laravel and Bootstrap - Microweb ...

CSS Styling for a Minimalist Web Design

I have been working on creating my own layout for a few hours now, but I am still encountering some issues. My goal is to achieve something like this: Specifically, I want the body of the page to be flexible, with a maximum width of 900px. However, I am s ...

Creating personalized categories with Material-UI's Autocomplete feature in a React application

I've been attempting to customize the groupings in the MUI Autocomplete component, but I haven't had any luck so far. It seems like there is no built-in solution provided by the library (I hope I'm mistaken). https://i.sstatic.net/NcJWU.png ...

Guide on removing a specific row from a MySQL database upon clicking the 'exit' button

Currently, I have implemented an upload button that is able to save various types of files into a MySQL table. Additionally, there is an exit button that I would like to use in order to delete any uploaded files if clicked. It's worth noting that all ...

Guide on restricting the character count and displaying the leftover characters using PHP with Ajax

I've been working on implementing a feature to display the remaining characters in a PHP AJAX call. I was successful using JavaScript, but I'm having trouble doing it with AJAX in PHP. Can someone provide assistance? <script type="text/javasc ...

What is preventing me from utilizing sliding images within a modal popup?

When I click on a button, a modal window opens with a carousel slider inside. However, I am experiencing issues with sliding on the chevron left and right buttons. On my computer, the images slide every 5 seconds, but on the JSFiddle platform, the sliding ...

Perfecting the CSS Flip Animation

My latest project involves creating a flip effect using CSS, and I need some assistance. You can check out my fiddle link here: https://jsfiddle.net/Munja/db11mmut/ The issue I am facing is that the back side of the element remains hidden until the front ...

When using React JSX, the style attribute does not recognize the object-fit property for images

When working with bootstrap cards, I encountered the need to make all images within the cards the same size. While there are various ways to achieve this, I used the following styling approach: Take a look at the image style below <div className=" ...

Encountering a problem during npm installation, where an error occurs due to being unable to read the property "match"

I'm encountering significant challenges when trying to install packages using npm. The output log I'm receiving is not helping me at all, and I'm unsure of where or how to address this issue. 0 info it worked if it ends with ok 1 verbose cli ...

Reducing the size of an internal label within a flex container

Hello everyone, I could really use some assistance here. The problem I'm facing involves a flex-container with tabs (the number of tabs can vary as they are passed as an array in a React component). Each tab consists of a label and a span with a numb ...

Angular checkbox utilizing an off-screen input element

Having an issue with Angular checkbox and would greatly appreciate any help: HTML: <span for="check" tabindex="0" role="checkbox" (click)="inputCheck.click()" (keydown)="keyEvent()"> <label for="check">checkbox</label> <input ...

Bootstrap sticky footer with adjustable height

Striving to achieve a sticky footer with a custom height on my website has turned out to be more challenging than I initially expected. Presented below is a snapshot of the current state of my footer: https://i.sstatic.net/SXaTA.png The issue arises whe ...

The functionality of $(selector).css() seems to be malfunctioning

I currently have an html div element stored in a variable var rows = ""; rows += "<div>1111 : Hi there</div>"; Despite multiple attempts, I have failed to add a background color to this div using the following methods: 1. $(rows).css({&apos ...

What is causing the issue with Shallow routing in Nextjs?

I've been experimenting with Shallow routing in Next.js to update the state in the URL without actually navigating to a new page, but I'm encountering unexpected behavior. In the scenario outlined below, I start on the home page using the URL: l ...

Using CSS modules with React libraries

Currently working on a React website, I decided to eject my project in order to use css modules styles. After running npm run eject, I made additional configurations in the webpack.config.dev.js and webpack.config.prod.js files. However, I encountered an i ...

Horizontal dropdown menus offer a sleek alternative to traditional vertical dropdown layouts

How can I fix this issue with my drop-down menu? It looks fine until I hover over it and the menu turns horizontal instead of vertical. Could it be a CSS problem? Thank you for your assistance! JS Fiddle HTML <body> <div id="wrapper"> < ...

Issue with Tooltip Position when Scrolling Sidebar is causing display problems

My goal is to create a Sidebar with Tooltip attached to its <li> elements similar to this example: Screenshot - Good Tooltip However, I am facing an issue where the position of the Tooltip breaks when scrolling to the bottom of the sidebar, causing ...

Ways to Customize the new Date() Function to Display Only Specific Fields

I am attempting to format my this.state.date to appear as DD/MM/YYYY. To achieve this, I utilized the library found at https://github.com/mmazzarolo/react-native-modal-datetime-picker Currently, I can select my desired date, however, when I assign it to t ...

Tips for validating a session on a React client following a successful authentication via an Express session

After setting up an express REST API backend and React Front End, the front end app redirects users to the signin page using OAuth. The express server then creates a session ID after successful authentication, which can be seen as a browser cookie connect. ...