Features Implemented:
Responsive 4-Column Layout:
- Uses CSS Grid for desktop view (4 columns)
- Switches to 2 columns on medium screens (tablets)
- Stacks to 1 column on mobile devices
Profile Column:
- Circular profile image with border
- Centered with caption
- Soft shadow and hover effect
Basic Details Column:
- Student name as heading
- Field of study as subheading
- Short bio paragraph
Portfolio Column:
- List of 5 projects with clickable links
- Hover effects for better interactivity
Contact Column:
- Contact form with name, email, and message fields
- JavaScript alert on form submission
- Download CV button with distinct styling
Design Elements:
- Clean, minimal aesthetic
- Soft shadows and rounded corners
- Hover animations for interactivity
- Professional color scheme
- Legible typography
Technical Implementation:
- Pure HTML, CSS, and JavaScript (no external libraries)
- CSS Grid for layout
- Media queries for responsiveness
- Simple form validation and feedback
The placeholder image can be replaced with an actual student photo by changing the src attribute in the profile image tag. Similarly, the download CV link can be updated to point to an actual PDF file.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}
body {
background-color: #f5f5f5;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.open-btn {
padding: 12px 24px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
transition: all 0.3s ease;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}
.open-btn:hover {
background-color: #45a049;
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
.modal-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
opacity: 0;
visibility: hidden;
transition: all 0.3s ease;
z-index: 1000;
}
.modal-overlay.active {
opacity: 1;
visibility: visible;
}
.modal {
background-color: white;
border-radius: 10px;
width: 90%;
max-width: 500px;
padding: 25px;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
transform: translateY(-50px);
transition: all 0.3s ease;
max-height: 90vh;
overflow-y: auto;
}
.modal-overlay.active .modal {
transform: translateY(0);
}
.modal-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}
.modal-header h2 {
color: #333;
font-size: 24px;
font-weight: 600;
}
.close-btn {
background: none;
border: none;
font-size: 24px;
cursor: pointer;
color: #777;
transition: color 0.3s ease;
}
.close-btn:hover {
color: #333;
}
.form-group {
margin-bottom: 15px;
}
.form-group label {
display: block;
margin-bottom: 5px;
font-weight: 500;
color: #555;
}
.form-group input,
.form-group select,
.form-group textarea {
width: 100%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 5px;
font-size: 14px;
transition: border-color 0.3s ease;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
border-color: #4CAF50;
outline: none;
}
.form-group textarea {
resize: vertical;
min-height: 80px;
}
.radio-group {
display: flex;
gap: 15px;
}
.radio-option {
display: flex;
align-items: center;
}
.radio-option input {
margin-right: 5px;
}
.error {
color: #e74c3c;
font-size: 12px;
margin-top: 5px;
display: none;
}
.form-group.invalid input,
.form-group.invalid select,
.form-group.invalid textarea {
border-color: #e74c3c;
}
.form-group.invalid .error {
display: block;
}
.form-actions {
display: flex;
justify-content: flex-end;
gap: 10px;
margin-top: 20px;
}
.btn {
padding: 10px 20px;
border: none;
border-radius: 5px;
font-size: 14px;
cursor: pointer;
transition: all 0.3s ease;
}
.btn-submit {
background-color: #4CAF50;
color: white;
}
.btn-submit:hover {
background-color: #45a049;
}
.btn-reset {
background-color: #f1f1f1;
color: #333;
}
.btn-reset:hover {
background-color: #ddd;
}
.success-message {
display: none;
text-align: center;
padding: 20px;
background-color: #dff0d8;
color: #3c763d;
border-radius: 5px;
margin-top: 20px;
}
@media (max-width: 480px) {
.modal {
width: 95%;
padding: 15px;
}
.radio-group {
flex-direction: column;
gap: 5px;
}
.form-actions {
flex-direction: column;
}
.btn {
width: 100%;
}
}
document.addEventListener('DOMContentLoaded', function() {
// DOM Elements
const openBtn = document.querySelector('.open-btn');
const modalOverlay = document.querySelector('.modal-overlay');
const closeBtn = document.querySelector('.close-btn');
const resetBtn = document.getElementById('resetBtn');
const form = document.getElementById('registrationForm');
const successMessage = document.getElementById('successMessage');
// Open modal
openBtn.addEventListener('click', function() {
modalOverlay.classList.add('active');
// Clear form and success message when reopening
form.reset();
successMessage.style.display = 'none';
// Remove error states
document.querySelectorAll('.form-group').forEach(group => {
group.classList.remove('invalid');
});
});
// Close modal
closeBtn.addEventListener('click', function() {
modalOverlay.classList.remove('active');
});
// Close modal when clicking outside
modalOverlay.addEventListener('click', function(e) {
if (e.target === modalOverlay) {
modalOverlay.classList.remove('active');
}
});
// Reset form
resetBtn.addEventListener('click', function() {
form.reset();
// Remove error states
document.querySelectorAll('.form-group').forEach(group => {
group.classList.remove('invalid');
});
});
// Form validation
function validateForm() {
let isValid = true;
// Validate Full Name
const fullName = document.getElementById('fullName');
if (!fullName.value.trim()) {
fullName.parentElement.classList.add('invalid');
isValid = false;
} else {
fullName.parentElement.classList.remove('invalid');
}
// Validate Email
const email = document.getElementById('email');
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (!emailRegex.test(email.value)) {
email.parentElement.classList.add('invalid');
isValid = false;
} else {
email.parentElement.classList.remove('invalid');
}
// Validate Phone
const phone = document.getElementById('phone');
const phoneRegex = /^[0-9]{10,15}$/;
if (!phoneRegex.test(phone.value)) {
phone.parentElement.classList.add('invalid');
isValid = false;
} else {
phone.parentElement.classList.remove('invalid');
}
// Validate Date of Birth
const dob = document.getElementById('dob');
if (!dob.value) {
dob.parentElement.classList.add('invalid');
isValid = false;
} else {
dob.parentElement.classList.remove('invalid');
}
// Validate Course
const course = document.getElementById('course');
if (!course.value) {
course.parentElement.classList.add('invalid');
isValid = false;
} else {
course.parentElement.classList.remove('invalid');
}
// Validate Gender
const genderSelected = document.querySelector('input[name="gender"]:checked');
const genderGroup = document.querySelector('.radio-group').parentElement;
if (!genderSelected) {
genderGroup.classList.add('invalid');
isValid = false;
} else {
genderGroup.classList.remove('invalid');
}
// Validate Address
const address = document.getElementById('address');
if (!address.value.trim()) {
address.parentElement.classList.add('invalid');
isValid = false;
} else {
address.parentElement.classList.remove('invalid');
}
return isValid;
}
// Form submission
form.addEventListener('submit', function(e) {
e.preventDefault();
if (validateForm()) {
// Store form data in localStorage
const formData = {
fullName: document.getElementById('fullName').value,
email: document.getElementById('email').value,
phone: document.getElementById('phone').value,
dob: document.getElementById('dob').value,
course: document.getElementById('course').value,
gender: document.querySelector('input[name="gender"]:checked').value,
address: document.getElementById('address').value
};
localStorage.setItem('studentRegistration', JSON.stringify(formData));
// Show success message
successMessage.style.display = 'block';
// Reset form after 3 seconds
setTimeout(() => {
form.reset();
successMessage.style.display = 'none';
modalOverlay.classList.remove('active');
}, 3000);
}
});
// Load saved data if exists (optional)
const savedData = localStorage.getItem('studentRegistration');
if (savedData) {
const formData = JSON.parse(savedData);
document.getElementById('fullName').value = formData.fullName;
document.getElementById('email').value = formData.email;
document.getElementById('phone').value = formData.phone;
document.getElementById('dob').value = formData.dob;
document.getElementById('course').value = formData.course;
document.querySelector(`input[name="gender"][value="${formData.gender}"]`).checked = true;
document.getElementById('address').value = formData.address;
}
});
Post a Comment
Thank you
Learning robo team