Build a Profile Card Website

王林
Release: 2024-08-24 11:21:35
Original
418 people have browsed it

Build a Profile Card Website

Introduction

Hello, developers! I'm excited to share my latest project: aProfile Card. This simple yet elegant project is a great way to showcase your front-end development skills while creating a reusable component for personal or professional use. Whether you're building a personal portfolio or a business website, this Profile Card can add a polished and professional touch to your web pages.

Project Overview

TheProfile Cardproject is a web-based component that displays a user's profile picture, name, status, and a brief description. It's designed to be interactive, allowing users to add or remove friends with just a click of a button. This project demonstrates how to work with dynamic content, event listeners, and conditional rendering using JavaScript.

Features

  • Interactive Design: Users can interact with the profile card by adding or removing friends.
  • Responsive Layout: The card is designed to look great on various devices and screen sizes.
  • Dynamic Content: The profile card dynamically updates its content based on user interactions.

Technologies Used

  • HTML: Provides the structure for the profile card.
  • CSS: Styles the card, ensuring it is visually appealing and responsive.
  • JavaScript: Handles the interactive features, such as updating the card's status and re-rendering content.

Project Structure

Here's an overview of the project structure:

Profile-Card/ ├── index.html ├── style.css └── script.js
Copy after login
  • index.html: Contains the HTML structure for the Profile Card.
  • style.css: Includes CSS styles for a clean, modern design.
  • script.js: Manages the dynamic aspects of the card, such as user interactions and status updates.

Installation

To get started with the project, follow these steps:

  1. Clone the repository:

    git clone https://github.com/abhishekgurjar-in/Profile-Card.git
    Copy after login
  2. Open the project directory:

    cd Profile-Card
    Copy after login
  3. Run the project:

    • Open the index.html file in a web browser to view the Profile Card.

Usage

  1. Open the websitein a web browser.
  2. View the Profile Carddisplaying the user's information.
  3. Interact with the cardby clicking the "Add Friend" or "Remove Friend" button to update the user's status.

Code Explanation

HTML

The index.html file defines the structure of the Profile Card, including the header, main content area, and footer. Here’s a snippet:

     Profile Card   

Profile Card

Copy after login

CSS

The style.css file styles the Profile Card, ensuring it's visually appealing and responsive. Below are some key styles:

body { width: 100%; height: 100%; } .header { font-family: sans-serif; margin: 50px; text-align: center; } #main { display: flex; align-items: center; justify-content: center; gap: 20px; width: 100%; height: 65vh; } #card { display: flex; flex-direction: column; align-items: center; padding: 20px; border-radius: 10px; width: 200px; height: 300px; background-color: #ffffff; } #card #img { width: 60px; height: 60px; border-radius: 50%; margin-bottom: 10px; overflow: hidden; } #card button { padding: 12px 22px; color: #fff; border: none; border-radius: 5px; } .footer { margin: 50px; text-align: center; }
Copy after login

JavaScript

The script.js file contains the logic for dynamically generating the Profile Cards and handling user interactions. Here's a snippet:

var arr = [ { name: "Alexander", img: "https://images.unsplash.com/photo-1506794778202-cad84cf45f1d?q=80&w=1887&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D", status: "Stranger", }, { name: "Alex", img: "https://images.unsplash.com/photo-1549780101-0c96c7eafbd9?q=80&w=1886&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D", status: "Stranger", }, ]; function print() { var clutter = ""; arr.forEach(function (val, index) { clutter += `

${val.name}

${val.status}

Lorem ipsum dolor sit amet consectetur adipisicing elit. Mollitia consequatur nobis natus. Provident?

`; }); document.querySelector("#main").innerHTML = clutter; } print(); document.querySelector("#main").addEventListener("click", function (details) { arr[details.target.id].status = "Friends"; print(); });
Copy after login

Live Demo

You can check out the live demo of the Profile Card project here.

Conclusion

The Profile Card project was an enjoyable experience, allowing me to practice essential front-end skills such as HTML, CSS, and JavaScript. I hope this project inspires you to create your own interactive components and continue honing your development skills. Happy coding!

Credits

This project was developed as part of my continuous learning journey in front-end development, with a focus on creating interactive and reusable web components.

Author

  • Abhishek Gurjar
    • GitHub Profile

The above is the detailed content of Build a Profile Card Website. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!