Concept
Your question entails achieving a grid layout similar to the one shown in your desired end result. Essentially, you need a grid box with 4 boxes per row. Below are examples of how the content will occupy spaces within multiple boxes:
https://i.sstatic.net/XQKQKYcg.png
You can modify the concept to resemble this structure:
https://i.sstatic.net/E4R09PoZ.png
Solution (based on your code)
The following modifications have been made based on your existing code, with minimal changes that work well in full-screen mode:
@import url('https://fonts.googleapis.com/css2?family=Barlow+Semi+Condensed:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');
*{
font-family: "Barlow Semi Condensed", sans-serif;
font-weight: 400;
font-style: normal;
}
#general-container{
display: grid;
gap: 1rem; /* added to get the spacing between boxes */
grid-template-columns: repeat(4, 1fr);
}
/* Additional CSS styles for different sections and elements */
.testimony-one{
background-color: hsl(263, 55%, 52%);
border-radius: 10px;
grid-column: span 2;
}
[other testimonial classes and their respective styles]
.testimony-five aside{
display: flex;
align-items: center;
justify-content: center;
}
[testimony individual styling as per requirements]
The Way I Would Approach This
To address this problem, my approach includes the following:
@import url('https://fonts.googleapis.com/css2?family=Barlow+Semi+Condensed:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
* {
font-family: "Barlow Semi Condensed", sans-serif;
font-weight: 400;
font-style: normal;
}
#general-container {
max-width: 1200px;
margin: 0 auto;
display: grid;
gap: 1rem;
grid-template-columns: repeat(4, 1fr);
}
/* Individual styling for testimonials */
.testimonial {
border-radius: 20px;
border: 1px solid black;
padding: 1.5rem;
}
.info {
position: relative;
display: flex;
gap: 1rem;
align-items: center;
}
/* Specific styling for first, last, and nth-child testimonials */
.testimonial:first-child,
.testimonial:nth-child(4) {
grid-column: span 2;
}
.testimonial:last-child {
grid-column: 4;
grid-row: 1 / 3;
}
.additional testimonial styling for unique designs
What I have modified
In the HTML, I standardized all testimonies under the testimonial
class for consistent styling across all elements. In the CSS, I utilized pseudo-classes like :first-child
, :last-child
, and :nth-child()
for manageable styling of different testimonials.
Key Concepts
The solution incorporates the usage of span
in grid-column
to allow items to occupy multiple grid boxes horizontally. Additionally, techniques such as grid-row: span
and grid-area
were explored for vertical alignment control within the grid layout.
Things That Are Not Covered Here
While focusing primarily on aligning testimonial boxes correctly, aspects like container width management, aesthetic enhancements, and responsive design implementations were not addressed but can be included according to project requirements.