0
Hi Gcobani Mkontwana,
To enhance the alignment of the "Choose file" input in your HTML code, you can modify the CSS styles and structure slightly. The goal is to ensure that the file input aligns well with the label and maintains a centered appearance.
<div class="stu-db">
<div class="container pg-inn d-flex justify-content-center align-items-center flex-column" style="max-width: 600px; padding: 15px;">
<div class="text-center">
<img id="profile-preview"
src="<?php echo htmlspecialchars($_SESSION['profile_image'] ?? 'images/user.jpg'). '?' . time(); ?>"
alt="Profile Image"
class="img-fluid rounded-circle mb-3"
style="width: 150px; height: 150px;">
<br><br>
<form id="saveProfileForm" action="save_image.php" method="post" enctype="multipart/form-data">
<div class="d-flex align-items-center justify-content-center mb-3" style="gap: 10px;">
<label for="profilePicture" class="form-label">Edit Profile Picture:</label>
<input type="file" class="form-control file-input" name="profilePicture" id="profilePicture" accept="image/*" required>
</div>
<button type="submit" class="btn btn-primary btn-lg mt-3">Save Image</button>
</form>
</div>
</div>
</div>
<style>
.file-input {
display: inline-block;
max-width: 250px;
padding: 5px;
}
.form-label {
margin-bottom: 0;
font-weight: 500;
margin-right: 10px;
}
.d-flex {
width: 100%;
justify-content: center; /* Center the label and input */
}
</style>
Key Changes
- Flexbox Alignment: Added
justify-content: center;
to the .d-flex
class to center the label and input together.
- Removed Unnecessary Styles: Simplified the CSS for better readability and maintainability.
