1. Home
  2. Ecommerce Rest Api
  3. React Frontend
  4. styles

styles

global.css

/* src/styles/global.css */
body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

header {
  background-color: #333;
  color: #fff;
  padding: 1rem;
}

header nav ul {
  list-style: none;
  display: flex;
  justify-content: space-around;
}

header nav ul li a {
  color: #fff;
  text-decoration: none;
}

.hero {
  background-color: #f4f4f4;
  padding: 2rem;
  text-align: center;
}

.product-listing {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
}

.product-card {
  border: 1px solid #ccc;
  padding: 1rem;
  margin: 1rem;
  width: 200px;
  text-align: center;
}

.product-details {
  padding: 2rem;
  text-align: center;
}

.cart, .checkout {
  padding: 2rem;
}

Import CSS in index.js

Import the global CSS styles in the index.js file.

// src/index.js
import React from 'react';
import ReactDOM from 'react-dom';
import './styles/global.css';
import App from './App';

ReactDOM.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
  document.getElementById('root')
);

How can we help?