Creating a beautifully aesthetic website using HTML, CSS, JavaScript, and React requires a framework setup. Below, I will outline a simple React application that is styled with CSS to give it an aesthetic appearance.
Setting Up Your React App
-
Install Node.js and npm: Ensure you have Node.js and npm installed on your machine. You can download it from Node.js official website.
-
Create a React App: Use Create React App to bootstrap a new React project. Open your terminal and run:
npx create-react-app my-aesthetic-website
cd my-aesthetic-website
-
Replace the Source Files: Replace the contents in src folders with the code provided below.
1. File Structure
Navigate to your src folder, and create three new components: Header.js, Home.js, and Footer.js.
2. Code for the Components
src/Header.js
import React from "react";
import "./Header.css";
function Header() {
return (
<header className="header">
<h1>My Aesthetic Website</h1>
<nav>
<a href="#home">Home</a>
<a href="#about">About</a>
<a href="#services">Services</a>
<a href="#contact">Contact</a>
</nav>
</header>
);
}
export default Header;
src/Home.js
import React from "react";
import "./Home.css";
function Home() {
return (
<div className="home">
<section id="about">
<h2>About Us</h2>
<p>We create stunning websites tailored just for you.</p>
</section>
<section id="services">
<h2>Our Services</h2>
<p>Web Development, Design, SEO, & Marketing Services.</p>
</section>
<section id="contact">
<h2>Contact Us</h2>
<p>Email: contact@example.com</p>
</section>
</div>
);
}
export default Home;
src/Footer.js
import React from "react";
import "./Footer.css";
function Footer() {
return (
<footer className="footer">
<p>© 2023 My Aesthetic Website</p>
</footer>
);
}
export default Footer;
3. Main App.js
Replace the contents of src/App.js with:
import React from "react";
import Header from "./Header";
import Home from "./Home";
import Footer from "./Footer";
import './App.css';
function App() {
return (
<div className="App">
<Header />
<Home />
<Footer />
</div>
);
}
export default App;
4. CSS Styles
Create CSS files for each component for styling the website. Below are examples of how you can give your site a beautiful, aesthetic feel.
src/Header.css
.header {
background: linear-gradient(135deg, #ffafbd, #ffc3a0);
color: #fff;
padding: 20px;
text-align: center;
}
.header nav {
margin-top: 10px;
}
.header nav a {
margin: 0 15px;
color: #fff;
text-decoration: none;
font-weight: bold;
}
src/Home.css
.home {
text-align: center;
padding: 50px;
background: #f9f9f9;
}
.home section {
margin: 30px 0;
padding: 20px;
background: white;
border-radius: 10px;
box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
}
.home h2 {
color: #35424a;
}
src/Footer.css
.footer {
background: #35424a;
color: white;
text-align: center;
padding: 10px 0;
position: absolute;
bottom: 0;
width: 100%;
}
src/App.css
.App {
display: flex;
flex-direction: column;
min-height: 100vh;
}
5. Run the Application
-
After replacing the files, navigate back to your terminal.
-
Run the following command to start your development server:
npm start
-
Open your browser and navigate to http://localhost:3000 to view your new aesthetic website.
Conclusion
This simple React application demonstrates how to set up an aesthetically pleasing website with HTML, CSS, and JavaScript (via React). You can expand upon this by adding more styles, animations, and interactive elements as you learn more about React and web development principles.