Table of Contents
Creating an attractive and responsive team members section is essential for many websites. Using CSS Flexbox allows you to design a flexible layout that adapts to different screen sizes. In this article, we will build a simple yet effective team members section with profile cards using Flexbox.
Setting Up the Container
First, create a container that will hold all the profile cards. This container will be styled with Flexbox properties to arrange the cards horizontally and wrap them as needed.
Here’s the basic HTML structure:
<div class="team-container">
<div class="profile-card"> ... </div>
<div class="profile-card"> ... </div>
<div class="profile-card"> ... </div>
</div>
Applying Flexbox Styles
Use CSS to style the container with Flexbox properties. Set display: flex and enable wrapping with flex-wrap: wrap. Adjust spacing with gap.
Sample CSS:
.team-container {
display: flex;
flex-wrap: wrap;
gap: 20px;
justify-content: center;
}
Designing the Profile Cards
Each profile card can be styled with a fixed width, padding, border, and shadow to make it stand out. Inside each card, include a profile image, name, role, and a brief description.
Example HTML for a profile card:
<div class="profile-card">
<img src="profile.jpg" alt="Team Member" class="profile-image"/>
<h3 class="name">John Doe</h3>
<p class="role">Developer</p>
<p class="description">John is a skilled developer with 5 years of experience.</p>
</div>
Styling the Profile Cards
Apply CSS styles to make the cards visually appealing. Example styles include setting width, background color, border-radius, and box-shadow.
Sample CSS:
.profile-card {
width: 200px;
background-color: #fff;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
padding: 15px;
text-align: center;
}
.profile-image {
width: 100px;
height: 100px;
border-radius: 50%;
object-fit: cover;
margin-bottom: 10px;
}
.name {
font-size: 1.2em;
margin: 10px 0 5px 0;
}
.role {
color: #777;
margin-bottom: 10px;
}
.description {
font-size: 0.9em;
color: #555;
}
Final Layout Tips
Ensure your CSS is included in your website’s stylesheet or within a style tag in the header. Adjust the widths and gaps to suit your design preferences. The Flexbox layout will automatically adjust as the screen size changes, maintaining a clean and organized appearance.
With these steps, you can create a responsive, attractive team members section that highlights your team effectively.