Create a row and column container with HTML and CSS only.

To create a well shaped container using HTML and CSS only (no boostrap require ) you can use the following method (i will illustrate an example of 3 columns):

HTML CODE

<div class=”container grid grid–3-cols”>
<div class=”d…


This content originally appeared on DEV Community and was authored by Root Lindow

To create a well shaped container using HTML and CSS only (no boostrap require ) you can use the following method (i will illustrate an example of 3 columns):

HTML CODE

<div class="container grid grid--3-cols">
    <div class="div-one">
        <p>Lorem ipsum tbum</p>
    </div>
    <div class="div-two">
        <p>Lorem ipsum tbum</p>
    </div>
    <div class="div-three">
        <p>Lorem ipsum tbum</p>
    </div>
</div>

CSS CODE

.container {
  max-width: 120rem;
  padding: 0 3.2rem;
  margin: 0 auto;
}
/* the gap gives the space between the columns */
.grid {
  display: grid;
  column-gap: 6.4rem;
  row-gap: 9.6rem; 
}

/* for 2 columns*/
.grid--2-cols {
  grid-template-columns: repeat(2, 1fr);
}

/* for 3 columns*/
.grid--3-cols {
  grid-template-columns: repeat(3, 1fr);
}

/* for 4 columns*/
.grid--4-cols {
  grid-template-columns: repeat(4, 1fr);
}


This content originally appeared on DEV Community and was authored by Root Lindow


Print Share Comment Cite Upload Translate Updates
APA

Root Lindow | Sciencx (2022-01-25T11:46:00+00:00) Create a row and column container with HTML and CSS only.. Retrieved from https://www.scien.cx/2022/01/25/create-a-row-and-column-container-with-html-and-css-only/

MLA
" » Create a row and column container with HTML and CSS only.." Root Lindow | Sciencx - Tuesday January 25, 2022, https://www.scien.cx/2022/01/25/create-a-row-and-column-container-with-html-and-css-only/
HARVARD
Root Lindow | Sciencx Tuesday January 25, 2022 » Create a row and column container with HTML and CSS only.., viewed ,<https://www.scien.cx/2022/01/25/create-a-row-and-column-container-with-html-and-css-only/>
VANCOUVER
Root Lindow | Sciencx - » Create a row and column container with HTML and CSS only.. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/01/25/create-a-row-and-column-container-with-html-and-css-only/
CHICAGO
" » Create a row and column container with HTML and CSS only.." Root Lindow | Sciencx - Accessed . https://www.scien.cx/2022/01/25/create-a-row-and-column-container-with-html-and-css-only/
IEEE
" » Create a row and column container with HTML and CSS only.." Root Lindow | Sciencx [Online]. Available: https://www.scien.cx/2022/01/25/create-a-row-and-column-container-with-html-and-css-only/. [Accessed: ]
rf:citation
» Create a row and column container with HTML and CSS only. | Root Lindow | Sciencx | https://www.scien.cx/2022/01/25/create-a-row-and-column-container-with-html-and-css-only/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.