To improve the visual formatting of your HTML webpage, we can add some CSS styles to enhance the layout, typography, and responsiveness of the elements. Below is a basic CSS stylesheet that you can include in your style.css
file to achieve a cleaner and more user-friendly look:
CSS (style.css)
/* General Styles */
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4; /* Light background color */
margin: 0;
padding: 20px;
}
h1 {
color: #333; /* Dark text color */
text-align: center;
}
/* Container for user entries */
.user-container {
max-width: 800px;
margin: 0 auto; /* Centering the container */
padding: 20px;
background-color: #fff; /* White background for contrast */
border-radius: 8px; /* Rounded corners */
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); /* Subtle shadow */
}
/* Individual user entry styles */
.user-entry {
display: flex; /* Flexbox for horizontal alignment */
justify-content: space-between; /* Space out items */
align-items: center; /* Center alignment */
padding: 10px;
border-bottom: 1px solid #ddd; /* Separation between entries */
}
.user-entry:last-child {
border-bottom: none; /* Remove border from the last child */
}
/* Button styles */
button {
padding: 8px 12px;
margin-left: 5px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 14px;
}
button[name="accept"] {
background-color: #28a745; /* Green button for acceptance */
color: white;
}
button[name="delete"] {
background-color: #dc3545; /* Red button for deletion */
color: white;
}
button[name="revoke"] {
background-color: #ffc107; /* Yellow button for revocation */
color: black;
}
button:hover {
opacity: 0.9; /* Slightly transparent on hover */
}
HTML Modifications
You will also need to apply some classes to your HTML structure so that the styles are reflected correctly. Here's how to modify your PHP code that generates the user entries:
if ($result) {
echo '<div class="user-container">'; // Start user container
while ($userRow = mysqli_fetch_assoc($result)) {
echo '<div class="user-entry">'; // User entry class
echo 'First Name: ' . $userRow['first_name'] . ' - Last Name: ' . $userRow['last_name'] . ' - Username: ' . $userRow['username'] . ' - Address: ' . $userRow['address'] . ' - ' . ($userRow['verified'] ? 'Verified' : 'Not Verified');
// Create a form with action buttons
echo '<form method="POST" style="display:inline-block;">';
echo '<input type="hidden" name="userId" value="' . $userRow['user_id'] . '">';
if (!$userRow['verified']) {
echo '<button type="submit" name="accept">Accept</button>';
echo '<button type="submit" name="delete">Delete</button>';
} else {
echo '<button type="submit" name="revoke">Revoke</button>';
}
echo '</form>';
echo '</div>'; // Close user entry
}
echo '</div>'; // Close user container
} else {
echo "Error in query: " . mysqli_error($conn);
}
Summary
- CSS file: The provided CSS styles enhance the background, text, layout, and button styles for better aesthetics.
- HTML modifications: Implementing the appropriate class names will help your CSS apply correctly to each user entry.
Once you apply these styles and modifications, your webpage should look more organized and visually appealing. Feel free to adjust the styles to better fit your desired design!