Looking for a solution to align the header properly in your React app?

Struggling with aligning a header? The CSS property of the header is inherited from the app's CSS file. For example, in the image below, "Our Mission" is the header that needs to be left-aligned. Looking for some assistance here. You can find the app.js and app.css files in this CodeSandbox link: https://codesandbox.io/s/summer-hooks-527rx9?file=/src/App.js

https://i.sstatic.net/lJXht.jpg

https://codesandbox.io/s/summer-hooks-527rx9?file=/src/App.js

app.js:

import "./styles.css";

export default function App() {
  return (
    <div id="app">
      <img id="home-background-image" />
      <div id="project-header">
        <p id="project-exp">Test Site Name</p>
      </div>

      <div id="project-mission-header">
        <h2>Our Mission</h2>
      </div>
    </div>
  );
}

styles.css

#app {
  font-family: sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#home-background-image {
  width: 100%;
  height: 350px;
  background: url("https://png.pngtree.com/thumb_back/fh260/background/20201026/pngtree-futuristic-shape-abstract-background-chemistry-technology-concept-for-website-image_438818.jpg");
  background-size: cover;
}

#project-header {
  position: absolute;
  top: 100px;
  color: white;
}
#project-exp {
  font-size: 3rem;
  font-weight: 600;
  margin: 0;
}

#project-mission-header {
  width: 810px;
  justify-content: left;
}

Answer №1

Simply adjust the width to 100%

#project-mission-header {
  width: 100%;
  justify-content: left;
}

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

Retrieving CSS file using admin-ajax.php in WordPress

The website has been tested on GTmetrix and you can view the report here I am puzzled as to why admin-ajax.php is causing a delay of over 3 seconds in loading time on this particular page that I am attempting to optimize. It seems to be related to a CSS ...

The theme font fails to take effect on the paragraph

As a novice in HTML and CSS, I attempted to use the "Roboto Condensed" font from a WordPress theme for my entire site. Although I successfully implemented this custom font for a menu, I encountered difficulties when trying to apply it to paragraph elements ...

Error: Surprising token found in ReactJS application on CodeSandbox

Encountering an unexpected token on line 5 error in my ReactJS project when testing it on CodeSandbox. Interestingly, the app runs smoothly without errors on my local machine. import React, { Component } from 'react'; import Header from ' ...

Design a dynamic dropdown feature that is triggered when the chip element is clicked within the TextField component

Currently, I am facing difficulties in implementing a customized dropdown feature that is not available as a built-in option in Material UI. All the components used in this project are from Material UI. Specifically, I have a TextField with a Chip for the ...

Is there a way to simultaneously run both my Node application and React app with just one command?

I am planning to create a boilerplate for React and Node, with the following root folder structure: - (root level) - client - src - public - package.json - ... - package.json - server.js - node_module ...

create-react-app insert personalized configuration variable

I am looking to incorporate custom environment variables into my React project using a boilerplate setup. Within my development (DEV) environment, I would like to direct the API towards my localhost backend, while in production (PROD) environment, it shoul ...

Instructions on changing the color and font weight of an asterisk within a Textfield using Material UI

Is there a way to style the asterisk in red and bold within a Textfield using material UI? I have a placeholder text without a label, as my label is null or empty. I would like to make the placeholder star RED. Is this possible? Here is the code snippet: h ...

What is the best way to retrieve variables from child components within a parent component in React?

I'm currently diving into React by working on a form/calculator application. I've come to realize that React follows a unidirectional pattern, and I'm struggling with how to deal with it. My goal is to create a table where users can input i ...

The table borders in IE 11 do not display properly when using Html5 and CSS

In a previous version, the table had visible borders. However, when I added the property text-align:center; to my container, the table did not align to the center. I then tried adding display:inline-block; to the table, which successfully centered it. It l ...

Conflicting CSS selection elements in WordPress causing theme theme selection conflicts

Despite trying various edits to my custom CSS, such as including ::selection{color: white; background: #2f3f58;}, copying and pasting code from sites like W3Schools and stack overflow, nothing seemes to work. I am using the Hueman theme from , which has a ...

bootstrap3 container alignment

I encountered a challenge while attempting to right-align multiple Bootstrap 3 containers in a straightforward manner. Despite my efforts, achieving this proved to be more complex than expected. In essence, I faced an issue where aligning the text box with ...

Encounter issue when attempting to insert multiple items into MongoDB

// Import User and Item Models const User = require('../../models/User'); const Item = require('../../models/Item'); router .post('/login/:id', passport.authenticate('jwt', {session: false}), (req, res) => { ...

Error encountered during Nuxt build: Syntax error on Line 1 of the SCSS component file

I'm currently working on a project in node 18.7.0 that utilizes nuxt 2.15.8. Within my Vue component, I have the following SCSS code: <style lang="scss"> .Accordion { --Accordion__margin-top: 2.5rem; &__items { margin ...

Divide information in the chart

<table id="tab"> <tr><td class="sub">mmmmm</td><td class="sub">jjjjj</td></tr> <tr><td class="sub">lllll</td><td class="sub">wwwww&l ...

How to adjust background size for Iphone4 and Iphone5 simulators using only HTML5 and CSS3 code

Creating an HTML5 app for iPhone4 and 5 with a texture-rich background. I'm facing an issue where the texture image gets scaled and only the central part is visible, even though the image size is 640x960 and 640x1136. I've tried adding @2x at the ...

Having difficulty refreshing the chosen value post-rendering

I'm facing an issue with autocomplete where the selected value does not refresh after being rendered. I have provided an example at : https://codesandbox.io/s/test-material-ui-autocomplete-700nh?fontsize=14&hidenavigation=1&theme=dark import ...

What is the best way to choose an HTML element based on the attributes of its child nodes in CSS?

Take this scenario for instance: <tr> <td align="center">123</td> <td class="someclass">abc</td> </tr> My goal is to target all <tr> elements that contain a <td> with the class attribute set to someclass. ...

jQuery UI Datepicker Display Issue

I'm encountering an issue with a jQuery UI Datepicker object that is supposed to appear when I click inside a textbox. Below is the HTML code: <tr> <td class="label-td"><label for="dateOpen_add">Date Opened</label></td& ...

The function "classList.add" does not successfully add a class to both a div and form elements

I've encountered an issue where I am unable to add a class to div/form elements using the classList.add method. Interestingly, this method works perfectly fine for other elements like input or button. However, when it comes to the div and form element ...

Tips for designing a masonry grid with Bootstrap 4

I'm attempting to achieve a specific layout using Bootstrap 4, JavaScript, CSS, and HTML. I have not been able to find something similar on Stack Overflow, but I did come across the Bootstrap 4 Cards documentation. However, I am unsure if this is the ...