Create a Toggle Profile Card Details using HTML CSS and JavaScript Last Updated : 23 Jul, 2024 Comments Improve Suggest changes Like Article Like Report In this article, we will develop an interactive Toggle Profile Card Details application using HTML, CSS, and JavaScript Language. In this application, we have a Card Component with the user's details like their profile picture and Name. There is a toggle button, and when the button is clicked, the detailed information of the user will be displayed for example Email, Address, Interest, and Social Media Links.Preview PrerequisitesHTMLCSSJavaScriptApproachCreate the HTML structure by using the HTML tags. We have used h1 to represent the GeeksforGeeks heading and h3 for the Application Name.Then by using the external CSS CDN link, we have created the toggle icon and social media links.The entire card component, icons, are been styled using a CSS file. Entire colors, effects, and animations are defined in the CSS file by using properties and classes.In the JavaScipt Code, firstly we store the reference of HTML elements of toggle-details and the card-details.We have used the click event listener, to perform the actual toggling effect.Example: This example illustrates the basic implementation of the Toggle Profile Card Details using HTML CSS and JavaScript. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="styles.css"> <link rel="stylesheet" href= "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css"> <link rel="stylesheet" href= "https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&display=swap"> <title>Toggle Profile Card</title> </head> <body> <header> <h1 class="logo">GeeksforGeeks</h1> <h3 class="subtitle"> Toggle Profile Card Details using HTML CSS & JavaScript </h3> </header> <div class="profile-card"> <div class="card-header"> <img src= "https://media.geeksforgeeks.org/wp-content/uploads/20230816191453/gfglogo.png" alt="Profile Picture"> <h2>GeeksforGeeks</h2> <div id="toggle-details" class="toggle-button"> <i class="fas fa-chevron-down"></i> </div> </div> <div class="card-details"> <p> <strong>Email:</strong>feedback@geeksforgeeks.org </p> <p> <strong>Location:</strong> A-143, 9th Floor, Sovereign Corporate Tower, Sector-136, Noida, Uttar Pradesh - 201305 </p> <p> <strong>Interests:</strong> Web Development, Design </p> <div class="social-icons"> <a href="#" class="icon-link"> <i class="fab fa-twitter"></i> </a> <a href="#" class="icon-link"> <i class="fab fa-facebook"></i> </a> <a href="#" class="icon-link"> <i class="fab fa-instagram"></i> </a> <a href="#" class="icon-link"> <i class="fab fa-linkedin"></i> </a> </div> </div> </div> <script src="script.js"></script> </body> </html> CSS body { font-family: 'Montserrat', sans-serif; background: linear-gradient(90deg, #f1a2ff, #caf072); margin: 0; padding: 0; } header { text-align: center; padding: 20px; color: #32CD32; font-size: 24px; font-weight: bold; } .logo { margin: 0; font-size: 36px; color: rgb(15, 149, 15); } .subtitle { margin: 0; font-size: 18px; color: black; } .profile-card { background-color: #e6f7ff; border-radius: 10px; box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.3); width: 400px; text-align: center; overflow: hidden; animation: fadeIn 1s ease-in-out; margin: 20px auto; } @keyframes fadeIn { 0% { opacity: 0; transform: translateY(-20px); } 100% { opacity: 1; transform: translateY(0); } } .card-header { background-color: #007bff; color: #fff; padding: 20px; position: relative; } .card-header img { width: 100px; height: 100px; border-radius: 50%; margin-bottom: 10px; border: 5px solid #fff; box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3); transition: transform 0.3s ease-in-out; } .card-header img:hover { transform: scale(1.1); } .toggle-button { background-color: #ff6f61; color: #fff; border: none; padding: 10px; cursor: pointer; transition: background-color 0.3s, color 0.3s, transform 0.3s; position: absolute; top: 50%; right: 20px; transform: translateY(-50%); border-radius: 50%; } .toggle-button:hover { background-color: #e7453d; } .card-details { display: none; padding: 20px; background: linear-gradient(90deg, #ff6f61, #ff7676); color: #fff; } .card-details p { margin: 10px 0; font-size: 16px; } .show-details { display: block; animation: slideIn 0.5s forwards; } @keyframes slideIn { 0% { transform: translateY(-20px); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } } .social-icons { margin-top: 20px; } .icon-link { font-size: 24px; margin-right: 10px; text-decoration: none; transition: color 0.3s; } .icon-link:nth-child(1) i { color: #e4405f; } .icon-link:nth-child(2) i { color: #1da1f2; } .icon-link:nth-child(3) i { color: #1877f2; } .icon-link:nth-child(4) i { color: #0077b5; } .icon-link:hover { color: #ff6f61; } JavaScript const tBtn = document.getElementById('toggle-details'); const profileDetails = document.querySelector('.card-details'); tBtn.addEventListener('click', () => { profileDetails.classList.toggle('show-details'); tBtn.querySelector('i').classList.toggle('fa-chevron-down'); tBtn.querySelector('i').classList.toggle('fa-chevron-up'); }); Output: Comment More infoAdvertise with us Next Article Create a Toggle Profile Card Details using HTML CSS and JavaScript G gauravggeeksforgeeks Follow Improve Article Tags : JavaScript Web Technologies Geeks Premier League JavaScript-Properties Geeks Premier League 2023 +1 More Similar Reads Create a Animated Product Card using HTML CSS & JavaScript. In this article, we dive into creating a simple animated product card using HTML, CSS, and JavaScript. Here we're going to create a product card with the product name and price. On hover, it flips and shows detailed information along with a buy button. These cards not only make the website visually 3 min read Design a Social Media Profile Card using HTML CSS & JavaScript To implement and Design a Social Media Profile Card using HTML CSS, and JavaScript language. In this application, we have created an attractive card component that represents the Social Media Profile information of the user. This information includes Profile Image, Name, Designation, Location, Follo 4 min read Create a Mobile Toggle Navigation Menu using HTML, CSS and JavaScript To create a Mobile Toggle Navigation Menu you need HTML, CSS, and JavaScript. If you want to attach the icons with the menu then you need a font-awesome CDN link. This article is divided into two sections: Creating Structure and Designing Structure.A glimpse of complete Navigation:Â Creating Structur 3 min read Light/Dark Mode User Profile Card using HTML CSS and JavaScript This article will show how to make an Animated User Profile Card using HTML, CSS, and JavaScript. We generally see these effects in portfolios of professionals. In this, we have created a code that generates a personalized card with the user's name, image, and description. Additionally, we've implem 3 min read Creating a Personalized Greeting Card with HTML CSS and JavaScript In this article, we are going to learn how to create a Personalized Greeting Card with HTML, CSS, and JavaScript.Output Preview:PrerequisitesHTMLCSSJavaScriptApproach:Create a JavaScript function called customizeCard.Utilize the prompt function to gather user input for a new greeting and a new messa 2 min read Design a Toggleable Sidebar using HTML CSS and JavaScript In this article, we will create a toggleable sidebar navigation menu using HTML, CSS, and JavaScript. The navigation menu allows users to open and close a sidebar to access various sections of a website. When the user clicks on a navigation item, the corresponding content is displayed in the main co 3 min read How to Create a Portfolio Website using HTML CSS and JavaScript ? A portfolio website is a website that represents you online on the web pages. It contains different sections like Introduction to Yourself, About You, Your Services, Your Contact Details, and Your Portfolio. We are going to build all of the sections with an interactive and attractive web design that 15+ min read Create a Product Detail Page Template using HTML and CSS In this article, we will create a Product Details Layout Template using HTML & CSS. This Card is generally used in e-commerce websites to make the product more presentable and show details clearly. The card-like structure includes details such as product name, price, and a concise description, p 4 min read How to create a revealing sidebar using HTML CSS and JavaScript? A revealing sidebar is a hidden UI element that becomes visible upon user interaction, such as clicking or swiping, providing navigation links. The content of the page will rotate and the navigation bar will reveal itself when the menu button is clicked. ApproachCreate an HTML file with headings and 3 min read How To Create Toggle Switch by using HTML and CSS? A toggle switch allows users to switch between two states, typically "on" and "off," and is commonly used in forms and interactive elements. To create a toggle switch, we will use HTML and CSS. We can add different styles to the checkbox element to create a toggle switch.1. Basic Circular Toggle Swi 3 min read Like