<?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: virensuthar</title>
    <description>The latest articles on DEV Community by virensuthar (@virensuthar).</description>
    <link>https://dev.to/virensuthar</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%2F435228%2F1ad4dd4e-7c8f-4b87-80fc-d76e1a74853d.jpeg</url>
      <title>DEV Community: virensuthar</title>
      <link>https://dev.to/virensuthar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/virensuthar"/>
    <language>en</language>
    <item>
      <title>Basics of CSS Grid</title>
      <dc:creator>virensuthar</dc:creator>
      <pubDate>Sun, 14 Mar 2021 08:46:49 +0000</pubDate>
      <link>https://dev.to/virensuthar/basics-of-css-grid-ga4</link>
      <guid>https://dev.to/virensuthar/basics-of-css-grid-ga4</guid>
      <description>&lt;h1&gt;
  
  
  CSS Grid
&lt;/h1&gt;

&lt;p&gt;=&amp;gt; CSS Grid is a layout based system used for placing elements in a grid format without using float and position properties. It's easy to use also used for making webpage responsive. Flexbox and Grid are the most important things to learn in modern CSS.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You can check my article on CSS Flexbox &lt;a href="https://dev.to/virensuthar/get-started-with-flexbox-3in5"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;=&amp;gt; Grid is structured on rows and column,  by using the grid you can place elements on rows and column in particular number and size and even place in a particular order. here is a basic guide so you can start implementing it in your CSS.&lt;/p&gt;

&lt;h1&gt;
  
  
  Using Grid
&lt;/h1&gt;

&lt;p&gt;Give property of &lt;code&gt;display: grid;&lt;/code&gt; to element for using flexbox.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;####  grid-template-columns&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;=&amp;gt; &lt;code&gt;grid-template-columns&lt;/code&gt; is used for placing grid elements across the column,&lt;br&gt;
like if you give 3 sizes it will divide your page into 3  columns.&lt;/p&gt;

&lt;p&gt;example : &lt;code&gt;grid-template-columns : 100px 100px 100px ;&lt;/code&gt; this will make 3 columns &lt;br&gt;
with the each column size of 100px, here you can play with numbers you can even pass &lt;code&gt;100px 200px 100px&lt;/code&gt;. You have to pass parameter as number of columns you want you have to pass 5 parameters for 5 columns.&lt;/p&gt;

&lt;p&gt;=&amp;gt; But if you want 10 columns this is not a good idea so the grid has a function &lt;code&gt;repeat()&lt;/code&gt; so this become easy to use, in repeat you pass the number of columns and the size of each element. Ex: &lt;code&gt;grid-template-column : repeat(5, 100px)&lt;/code&gt; it create 5 column size of 100px or &lt;code&gt;grid-template-column : repeat(5, 1fr)&lt;/code&gt; fr is fractional units it means it takes all amount of free space.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;####  grid-template-rows&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;=&amp;gt; &lt;code&gt;grid-template-rows&lt;/code&gt; is used for placing grid elements across the rows. All the properties are the same as &lt;code&gt;grid-template-columns&lt;/code&gt; but it all works in rows.&lt;/p&gt;

&lt;p&gt;=&amp;gt; Now giving space between grid elements you use &lt;code&gt;grid-gap&lt;/code&gt; also you can use ( &lt;code&gt;gap&lt;/code&gt; only)&lt;/p&gt;

&lt;p&gt;Ex: &lt;code&gt;grid-gap : 24px ;&lt;/code&gt; it place items with 24px of distance.&lt;/p&gt;

&lt;p&gt;Look at the image below all the above properties are summed up. 👇&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5h488h4e39g0f7agdo2p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5h488h4e39g0f7agdo2p.png" alt="Alt Text" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;grid-auto-columns : auto&lt;/code&gt; for implicitly created columns positioning (implicit: not created by you).&lt;/p&gt;

&lt;p&gt;&lt;code&gt;grid-auto-rows : auto&lt;/code&gt; for implicitly created rows positioning.&lt;/p&gt;

&lt;h3&gt;
  
  
  Placing grid items
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;grid-column-start : 2&lt;/code&gt; will place items in position 2 as possible.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;grid-column-end : 2&lt;/code&gt; it takes to position 5 and expanding.&lt;/p&gt;

&lt;p&gt;both can be written shortly like this &lt;code&gt;grid-column : 2/3&lt;/code&gt;&lt;br&gt;&lt;br&gt;
he same applies to rows also.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;span&lt;/code&gt; in a grid used for expanding element at its position with other elements size &lt;br&gt;
, like &lt;code&gt;grid-column: span 2/ 4&lt;/code&gt; means the first element will take the amount of space as equal to 2 elements.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;#### &lt;code&gt;minmax()&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ex : &lt;code&gt;minmax(150px, 1fr)&lt;/code&gt; this means element's minmun width will be 150px and maximum will be 1fr, this used in &lt;code&gt;grid-template-columns&lt;/code&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Tip: whenever you want to make the grid responsive do it this way it makes it responsive without using media query &lt;code&gt;grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));&lt;/code&gt; ( replace 300px size according to you.)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;#### grid alignment&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;unlike flexbox, you can centre things on a grid also.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;align-items: center&lt;/code&gt; and  &lt;code&gt;justify-items: center&lt;/code&gt; both can be written in shortly &lt;code&gt;place-items: center&lt;/code&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Best resource to learn CSS Grid is &lt;a href="https://cssgrid.io/" rel="noopener noreferrer"&gt;cssgrid.io&lt;/a&gt; course by &lt;a href="https://wesbos.com/" rel="noopener noreferrer"&gt;wesbos&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Thanks for reading 😊, please give your feedback I am trying to improve my blog by writing in a more structured way. 🙏&lt;/p&gt;

</description>
      <category>css</category>
      <category>html</category>
      <category>grid</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Get started with Flexbox.</title>
      <dc:creator>virensuthar</dc:creator>
      <pubDate>Fri, 04 Dec 2020 04:37:49 +0000</pubDate>
      <link>https://dev.to/virensuthar/get-started-with-flexbox-3in5</link>
      <guid>https://dev.to/virensuthar/get-started-with-flexbox-3in5</guid>
      <description>&lt;h1&gt;
  
  
  What is Flexbox?
&lt;/h1&gt;

&lt;p&gt;Flexbox is a layout in CSS3. Flexbox is used to make responsive layouts and components on a webpage. Using is a good choice to use in CSS so you can design the page responsively. Here is a basic guide to getting starting with flexbox.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ffsln7je4ax7ft3er28hh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ffsln7je4ax7ft3er28hh.png" alt="Alt Text" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Consider the above image and try to understand a layout there is one container, and inside that two elements are placed. This is an important part to understand, then using flexbox will be easy. Now plot that container into an x-y axis coordinate, horizontal part in flexbox called the Main axis and vertical part is called the Cross axis. &lt;/p&gt;

&lt;h1&gt;
  
  
  Using Flexbox
&lt;/h1&gt;

&lt;p&gt;Give property of &lt;code&gt;display: flex;&lt;/code&gt; to element for using flexbox.&lt;/p&gt;

&lt;h4&gt;
  
  
  Flex-direction
&lt;/h4&gt;

&lt;p&gt;Flex-direction property is used to give direction to element should be placed, four types of properties are defined.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;flex-direction: row;&lt;/code&gt; place flex-items in row (horizontal).&lt;/li&gt;
&lt;li&gt; &lt;code&gt;flex-direction: row-reverse;&lt;/code&gt; place flex-items in row but in reverse order.&lt;/li&gt;
&lt;li&gt; &lt;code&gt;flex-direction: column;&lt;/code&gt; place flex-items in column (vertical).&lt;/li&gt;
&lt;li&gt; &lt;code&gt;flex-direction: column-reverse;&lt;/code&gt; place flex-items in column but in reverse order.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can see in the example below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F4jkkaafn2ef4osrtmhyg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F4jkkaafn2ef4osrtmhyg.png" alt="Alt Text" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Flex-wrap
&lt;/h4&gt;

&lt;p&gt;Flex-wrap property is used for wrapping flex-items inside the flex-container.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;flex-wrap : nowrap&lt;/code&gt; will not wrap flex-item in flex-container.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;flex-wrap : wrap&lt;/code&gt; will wrap flex-item in flex-container if it not fit in container size.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can see in the example below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fkrxb50fi5gp2h4xi6fbj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fkrxb50fi5gp2h4xi6fbj.png" alt="Alt Text" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Justifying and aligning flex-item
&lt;/h3&gt;

&lt;p&gt;Now, this is a very important property of flexbox and you will use it regularly.&lt;br&gt;
Whenever we want to align flex-item to the Main axis (horizontally) use &lt;code&gt;justify-content&lt;/code&gt;, and if you want to align flex-items  to the Cross axis (vertically) use &lt;br&gt;
&lt;code&gt;align-items&lt;/code&gt;. Now let's see in detail.&lt;/p&gt;

&lt;h4&gt;
  
  
  Justifying content along with the Main axis (Horizontally).
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;justify-content: flex-start&lt;/code&gt; will place flex-item to the start of flex-container &lt;em&gt;(refer the first image above)&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;justify-content: flex-end&lt;/code&gt; will place flex-item to the end of flex-container&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;justify-content: center&lt;/code&gt; to center flex-items.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;justify-content: space-around&lt;/code&gt;`  space up around item.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&lt;/code&gt; justify-content: space-between &lt;code&gt;&lt;/code&gt; uses the whole frame and space item between.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&lt;/code&gt; justify-content: space-evenly &lt;code&gt;&lt;/code&gt; space all item evenly&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Aligning content along with the Cross axis (vertically).
&lt;/h4&gt;

&lt;p&gt;All properties are the same as  &lt;code&gt;&lt;/code&gt; justify-content &lt;code&gt;&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;&lt;/code&gt; align-items: flex-start &lt;code&gt;&lt;/code&gt; will place flex-item to the start of flex-container &lt;em&gt;(refer the first image above)&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&lt;/code&gt; align-items: flex-end &lt;code&gt;&lt;/code&gt; will place flex-item to the end of flex-containers&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&lt;/code&gt; align-items: center &lt;code&gt;&lt;/code&gt; to center flex-items.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&lt;/code&gt; align-items: baseline &lt;code&gt;&lt;/code&gt; place flex-item to base item.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Tip: Flexbox is a good option for centering things in CSS. Make sure whatever element you want to center their parent element would have width and height defined and give parent element &lt;code&gt;&lt;/code&gt; justify-content: center &lt;code&gt;&lt;/code&gt; and &lt;code&gt;&lt;/code&gt; align-items: center &lt;code&gt;&lt;/code&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading.&lt;/p&gt;

</description>
      <category>css</category>
      <category>html</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
