<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: webstuff</title>
    <description>The latest articles on DEV Community by webstuff (@detzam).</description>
    <link>https://dev.to/detzam</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F335702%2Fb34ce13f-c92d-4b8e-89e1-cd302ff15771.jpg</url>
      <title>DEV Community: webstuff</title>
      <link>https://dev.to/detzam</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/detzam"/>
    <language>en</language>
    <item>
      <title>Different ways of creating columns using css</title>
      <dc:creator>webstuff</dc:creator>
      <pubDate>Mon, 05 Jun 2023 00:45:04 +0000</pubDate>
      <link>https://dev.to/detzam/different-ways-of-creating-columns-using-css-12ji</link>
      <guid>https://dev.to/detzam/different-ways-of-creating-columns-using-css-12ji</guid>
      <description>&lt;p&gt;So here's a 5 minute read on this thing. &lt;br&gt;
i know it's not that interesting, but sometimes you need to get back to basics, if you don't know the basics you kinda struggle with advanced stuff.&lt;br&gt;
So... here's my take on creating columns or making grids in css.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;the display: inline-block approach
The idea is that the wrapper has some white-space that you need to remove. Then by using box-sizing you make the elements align better. you don't need the float, because inline-block will do it for you.
the Html is as follows:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="columns_container"&amp;gt;
    &amp;lt;div class="col col2"&amp;gt;column 1&amp;lt;/div&amp;gt;
    &amp;lt;div class="col col2"&amp;gt;column 2&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The CSS is like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.columns_container {
        display: block;
        max-width: 1200px;
        white-space: nowrap;
        font-size: 0;
        padding: 15px;
    background: gray;
    }

    .columns_container .col {
        display: inline-block;
        vertical-align: middle;
        box-sizing: border-box;
        white-space: normal;
        font-size: 18px;
    }

    .columns_container .col.col2 {
        width: 50%;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;the display: flex approach ( this one is popular now a days )
the HTML structure is as follows
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="columns_container_flex"&amp;gt;
    &amp;lt;div class="col col2"&amp;gt;column 1&amp;lt;/div&amp;gt;
    &amp;lt;div class="col col2"&amp;gt;column 2&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Css part&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.columns_container_flex {
                    max-width: 1200px;
                    display: flex;
                    flex-flow: row wrap;
                    padding: 15px;
                    background: #d8d8d8;
                }

                .columns_container_flex .col {
                    flex: 0 0 100%;

                }

                .columns_container_flex .col.col2 {
                    flex: 0 0 50%;
                }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;the display grid approach
Now this one is more for the future, but people online say it should be used with display flex, so that you create the wrapper with grid and you arange the content with display: flex&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The Html:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="columns_container_grid"&amp;gt;
    &amp;lt;div class="col col2"&amp;gt;column 1&amp;lt;/div&amp;gt;
    &amp;lt;div class="col col2"&amp;gt;column 2&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The css:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.columns_container_grid {
        max-width: 1200px;
        display: grid;
        grid-template-columns: 50% 50%;
        background-color: #2196F3;
        padding: 15px;
    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's my tale on this subject, hope it helped you guys.&lt;br&gt;
Have a great day!&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
