search

Home  >  Q&A  >  body text

box protocol in grid layout in css

I want the first two boxes to go up with maximum width and the second box to go down with maximum width, here is the code.

This is the CSS code:

/* Start Services  */
.services {
    padding-top: var(--section-pading);
    padding-bottom: var(--section-pading);
}
@media (min-widht: 768px) {
    .services .services-contianer {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(450px, 1fr));
    }
}
.services .box {
    display: flex;
}
.services .box i{
    margin-right: 50px;
}
.services .box h3{
    margin-bottom: 30px;
    color: var(--main-color);
}
.services .box p{
    line-height: 2;
}
/* End Services  */

This is the HTML code:

<!-- Start Services -->
    <div class="services">
        <div class="container">
            <div class="main-heading">
                <h2>Services</h2>
                <p> Curabitur arcu erat, accumsan id imperdiet et, porttitor at sem. Mauris 
                    blandit aliquet elit, eget tincidunt.
                </p>
            </div>
            <div class="services-container">
                <div class="box">
                    <i class="fa-solid fa-display fa-3x"></i>
                    <div class="text">
                        <h3>Vorem amet intuitive</h3>
                        <p>Curabitur arcu erat, accumsan id imperdiet et, porttitor at 
                            sem. Mauris blandit aliquet elit, eget tincidunt nibh pulvinar 
                            a. Curabitur aliquet quam.</p>
                    </div>
                </div>
            </div>
            <div class="services-container">
                <div class="box">
                    <i class="fa-solid fa-gear fa-3x"></i>
                    <div class="text">
                        <h3>Vorem amet intuitive</h3>
                        <p>Curabitur arcu erat, accumsan id imperdiet et, porttitor at 
                            sem. Mauris blandit aliquet elit, eget tincidunt nibh pulvinar 
                            a. Curabitur aliquet quam.</p>
                    </div>
                </div>
            </div>
            <div class="services-container">
                <div class="box">
                    <i class="fa-solid fa-pen-ruler fa-3x"></i>
                    <div class="text">
                        <h3>Vorem amet intuitive</h3>
                        <p>Curabitur arcu erat, accumsan id imperdiet et, porttitor at 
                            sem. Mauris blandit aliquet elit, eget tincidunt nibh pulvinar 
                            a. Curabitur aliquet quam.</p>
                    </div>
                </div>
            </div>
            <div class="services-container">
                <div class="box">
                    <i class="fa-solid fa-camera fa-3x"></i>
                    <div class="text">
                        <h3>Vorem amet intuitive</h3>
                        <p>Curabitur arcu erat, accumsan id imperdiet et, porttitor at 
                            sem. Mauris blandit aliquet elit, eget tincidunt nibh pulvinar 
                            a. Curabitur aliquet quam.</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- End Services -->

This is the result I get:

Enter image description here

I want the design to look like the picture below, I want 2 boxes up and 2 boxes down:

Enter image description here

Can you help?

P粉334721359P粉334721359230 days ago450

reply all(2)I'll reply

  • P粉194919082

    P粉1949190822024-04-04 15:59:41

    There are some errors in adding this style in this code.

    You can delete this code instead of doing this

    @media (min-widht: 768px) {
        .services .services-contianer {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(450px, 1fr));
        }
    }

    and add this CSS code hope you can achieve your desired output

    .container {
      display: flex;
      flex-wrap: wrap;
    }
    
    .services-container .box {
      width : 400px;
      min-width: 50%;
    }

    reply
    0
  • P粉863295057

    P粉8632950572024-04-04 11:47:36

    When I checked the code, there were spelling errors in the CSS code. I made some changes to the HTML code.

    Misspell:

    Please check the updated code below:

    /* Start Services  */
    .services {
        padding-top: var(--section-pading);
        padding-bottom: var(--section-pading);
    }
    @media (min-width: 768px) {
        .services .services-container {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(50%, 1fr));
    /*       background-color: red; */
        }
    }
    .services .box {
        display: flex;
    }
    .services .box i{
        margin-right: 50px;
    }
    .services .box h3{
        margin-bottom: 30px;
        color: var(--main-color);
    }
    .services .box p{
        line-height: 2;
    }
    /* End Services  */
     
        

    Services

    Curabitur arcu erat, accumsan id imperdiet et, porttitor at sem. Mauris blandit aliquet elit, eget tincidunt.

    Vorem amet intuitive

    Curabitur arcu erat, accumsan id imperdiet et, porttitor at sem. Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Curabitur aliquet quam.

    Vorem amet intuitive

    Curabitur arcu erat, accumsan id imperdiet et, porttitor at sem. Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Curabitur aliquet quam.

    Vorem amet intuitive

    Curabitur arcu erat, accumsan id imperdiet et, porttitor at sem. Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Curabitur aliquet quam.

    Vorem amet intuitive

    Curabitur arcu erat, accumsan id imperdiet et, porttitor at sem. Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Curabitur aliquet quam.

    reply
    0
  • Cancelreply