<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Harshiv Patel on Medium]]></title>
        <description><![CDATA[Stories by Harshiv Patel on Medium]]></description>
        <link>https://medium.com/@harshiv778?source=rss-78f56b091772------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*mJcpTfMjpJIZFGEqNjnaGA.png</url>
            <title>Stories by Harshiv Patel on Medium</title>
            <link>https://medium.com/@harshiv778?source=rss-78f56b091772------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 01:17:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@harshiv778/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[CSS Flexbox Layout module]]></title>
            <link>https://harshiv778.medium.com/css-flexbox-layout-module-e6d2585261df?source=rss-78f56b091772------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6d2585261df</guid>
            <category><![CDATA[html]]></category>
            <category><![CDATA[frontend-development]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[flexbox]]></category>
            <dc:creator><![CDATA[Harshiv Patel]]></dc:creator>
            <pubDate>Mon, 23 Jan 2023 06:48:44 GMT</pubDate>
            <atom:updated>2023-01-25T05:48:54.080Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*51Aot6IrCWU-QhMbfgtKFg.png" /></figure><p><strong>What is Flexbox?<br></strong>The <strong>flexbox </strong>is a flexible box designed to build one-dimensional layouts in CSS. One-dimensional means flexbox can build a layout in one dimension at one time. For two-dimensional layouts, use CSS Grids that can handle both rows and columns.</p><figure><img alt="Diagram of how flexbox works" src="https://cdn-images-1.medium.com/max/960/1*hbqrt3nxOEoZQOdFFAY_ig.jpeg" /><figcaption>Diagram of how flexbox works</figcaption></figure><p>A flexbox layout consists of a flex container (display: flex) that contains a flex item. Flex containers can be aligned horizontally (flex-direction: row or row-reverse ) or vertically (flex-direction: column or column-reverse ).</p><p>The direct children of a flex container are aligned along the main axis. These children can “flex” their sizes, growing to fill unused container space, or shrinking to avoid overflowing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*DrR-2URfn0qVpwdHPGAPbA.gif" /><figcaption>This is you guys right now, let’s make this definition simpler by exploring more about flexbox</figcaption></figure><p>The flex container properties are:<br>flex-direction| flex-wrap|flex-flow | justify-content| align-items| align-content</p><h3>Flexbox Elements</h3><p>To start using the flexbox model you need to define a flex container(display: flex).<br>Direct child elements of the flexible container automatically become flexible items.<br>Follow the code below, we will explore every property of flex</p><pre>&lt;!-- HTML CODE --&gt;<br>&lt;div class=&quot;container&quot;&gt;<br>  &lt;section class=&quot;flex-container&quot;&gt;<br>    &lt;div class=&quot;flex-item flex-item-1&quot;&gt; flex-item-1 &lt;/div&gt;<br>    &lt;div class=&quot;flex-item flex-item-2&quot;&gt; flex-item-2 &lt;/div&gt;<br>    &lt;div class=&quot;flex-item flex-item-3&quot;&gt; flex-item-3 &lt;/div&gt;<br>    &lt;div class=&quot;flex-item flex-item-4&quot;&gt; flex-item-4 &lt;/div&gt;<br>    &lt;div class=&quot;flex-item flex-item-5&quot;&gt; flex-item-5 &lt;/div&gt;<br>  &lt;/section&gt;<br>&lt;/div&gt;</pre><pre>/* CSS CODE */<br>* {<br>    padding: 0;<br>    margin: 0;<br>    box-sizing: border-box;<br>}<br><br>html,<br>body {<br>    height: 100%;<br>    width: 100%;<br>}<br><br>body {<br>    background-color: #eeeeee;<br>    color: #263238;<br>    padding: 60px 0;<br>}<br><br>.container {<br>    width: 80%;<br>    margin: 0 auto;<br>}<br><br>.flex-container {<br>    display: flex;  /* or inline-flex */<br>}<br><br>.flex-item {<br>    width: 300px;<br>    padding: 40px 80px;<br>    margin: 10px;<br>    text-transform: capitalize;<br>    background-color: #4a148c;<br>    color: white;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x6p3qI_UFBb6hmO7GWBrYA.png" /><figcaption>The output of the above code (Grey portion is the flex container and purple cards are its direct children’s.</figcaption></figure><h3>Parent Element (Flex Container)</h3><p>In our code flex-container is the parent container. Parent container property contains :</p><p>display| flex-direction|flex-wrap | flex-flow| justify-content| align-items| align-content</p><h4>display</h4><p>This defines a flex container; inline or block depending on the given value. It enables a flex context for all its direct children.</p><pre>.flex-container{<br>  display:flex; /* inline-flex */<br>}</pre><h4>flex-direction</h4><p>The flex-direction decides in which direction the child element of flex-container should flow (horizontal or vertical). By default, it is row(a horizontal direction).</p><pre>/*update the flex-container class in your css */<br>.flex-container{<br>  display: flex;<br>  flex-direction: column;<br>}</pre><pre>/*Try other flex-direction values:*/ <br>flex-direction: row|row- reverse|column|column-reverse|initial|inherit;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*O3wTzwKP69jjzP0r7zUW-w.png" /><figcaption>Output when you apply flex-direction: column</figcaption></figure><h4>flex-wrap</h4><p>The flex-wrap: wrap the value specifies that the flex items will wrap if necessary.</p><pre>//Add this property to your flex-container class<br>.flex-container{<br>  ...<br>  flex-wrap: wrap;<br>}</pre><pre>/*Try other flex-wrap values: */<br> flex-wrap: no-warp |wrap |wrap-reverse;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rbN857gfYTv25MSR7R2LVw.png" /><figcaption>The output of the above code</figcaption></figure><h4>flex-flow</h4><p>The flex-flow property is a shorthand property for setting both the flex-direction and flex-wrap properties.</p><pre>.flex-container {<br>  ...<br>  flex-flow: row wrap;<br>}</pre><h4>justify-content</h4><p>The justify-content property is used to align the flex items. Its default value is flex-start . Below we have used value center</p><pre>/*update the flex-container class in your css */<br>.flex-container {<br>  ...<br>  justify-content: center;<br>}<br><br>/*Try other justify-content values:*/ <br>justify-content: flex-start | flex-end | center | space-between | space-around | initial | inherit;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nRB_8I0WJjKh-CL-LrkzGQ.png" /><figcaption>The <em>center</em> value aligns the flex items at the center of the container</figcaption></figure><h4>align-items Property</h4><p>The align-items property is used to align the flex items vertically</p><pre>// Add this property to your flex-container class<br>.flex-container {<br>  ...<br>  align-items: center;<br>  background-color: black;<br>}</pre><pre>/*Try other align-item values: */<br>align-items: stretch | center | flex-start | flex-end | baseline | initial | inherit ;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7MtBgOrUMSJ_NWpnickBvA.png" /><figcaption>To demonstrate vertical alignment add height property to a flex-container class.</figcaption></figure><h4>align-content</h4><p>The align-content the property specifies how flex lines are distributed along the cross-axis in a flexbox container.</p><p>In the flexbox layout, the main axis is in the flex-direction (default is &#39;row&#39;, horizontal), and the cross axis is perpendicular to the main axis (default is &#39;column&#39;, vertical).</p><p><strong>Tip:</strong> Use the justify-content property to align the items on the main axis (horizontally)</p><pre>// Add this two property to your flex-container class<br>.flex-container{<br>  ...<br>  height: 800px;<br>  align-items: flex-start;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cn6w-3chPGGxZSCzkoYmxg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZG8r3hQ7XZ1SPapAv0GZww.png" /><figcaption>Difference between align-items: center and align-content: center</figcaption></figure><h3>Flex Child (flex-items)</h3><p>The flex item properties are:<br>flex-grow| flex-shrink|flex-basis | flex| align-self| align-self| order</p><h4>flex-grow</h4><p>flex-grow specifies how much the flex-item (child) would occupy the space available in its flex-container (parent).<br>Its default value is 0, considering all the flex-item haveflex-grow 1 then the available space will be distributed equally.<br>If one of the flex-item has a value of 3, that child will take up thrice as much of the space if available.</p><pre>.flex-item-3{<br>    flex-grow: 1;  //other values 2,3,4,..n<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s9sM5rTBgK1O1oNITufPgQ.png" /><figcaption>In the above example we kept 3 child element (flex-item) and gave flex-item-3 (3rd child) flex-grow:1. Try with flex-direction: column</figcaption></figure><h4>flex-shrink</h4><p>flex-shrinkspecifies how much the flex-item (child) would shrink compared to its sibling.</p><pre> &lt;section class=&quot;flex-container&quot;&gt;<br>    &lt;div class=&quot;flex-item flex-item-1&quot;&gt; flex-item-1 &lt;/div&gt;<br>    &lt;div class=&quot;flex-item flex-item-2&quot;&gt; flex-item-2 &lt;/div&gt;<br>    &lt;div class=&quot;flex-item flex-item-3&quot;&gt; flex-item-3 &lt;/div&gt;<br>    &lt;div class=&quot;flex-item flex-item-4&quot;&gt; flex-item-4 &lt;/div&gt;<br>    &lt;div class=&quot;flex-item flex-item-5&quot;&gt; flex-item-5 &lt;/div&gt;<br>&lt;/section&gt;</pre><pre>.flex-item-3{<br>    flex-shrink: 0;<br>}</pre><p>Please update your code accordingly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kZhunZ7UrR0ABgngP943Ig.png" /><figcaption>As we gave flex-shrink:0 to the 3rd child it didn’t shrink down from its original size, rather all the other children shrink down to fit into parents.</figcaption></figure><h4>flex-basis</h4><p>flex-shrink define the length of the element. Values can be 200px, 20rem, 20%,etc or auto . Update your stylesheet accordingly.</p><pre>.flex-item {<br>    /* width: 300px; */<br>    flex-basis: 400px;<br>}<br>.flex-item-3{<br>    flex-basis: 250px;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D3Nf0ZZ247cR2RpQCvIHZA.png" /><figcaption>The output of the above code</figcaption></figure><h4>flex</h4><p>flexis the shorthand property of flex-grow,flex-shrink, andflex-basis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*3IC9UjeDRvgWfbsLYpcANQ.png" /></figure><h4>order</h4><p>By default, the flex-items are displayed in source order, but by using the order property we can change its display order in flex-container.</p><pre>.flex-item-1 {<br>    order: 5;<br>}<br>.flex-item-2 {<br>    order: 4;<br>}<br>.flex-item-3 {<br>    order: 3;<br>}<br>.flex-item-4 {<br>    order: 2;<br>}<br>.flex-item-5 {<br>    order: 1;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cbwuIhaLzdTRWmVs4uDccw.png" /><figcaption>The output of the above code</figcaption></figure><h3>Few examples of flexbox</h3><ol><li><a href="https://codepen.io/harshiv7/pen/XWBZaGg"><strong>Demo 1</strong></a></li><li><a href="https://codepen.io/harshiv7/pen/dyjdVbq"><strong>Demo 2</strong></a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6d2585261df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[B.E.M. : Naming convention for CSS Classes]]></title>
            <link>https://harshiv778.medium.com/b-e-m-naming-convention-for-css-classes-f1e0cda5dc1d?source=rss-78f56b091772------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1e0cda5dc1d</guid>
            <dc:creator><![CDATA[Harshiv Patel]]></dc:creator>
            <pubDate>Tue, 23 Feb 2021 12:46:10 GMT</pubDate>
            <atom:updated>2021-02-23T12:46:10.385Z</atom:updated>
            <content:encoded><![CDATA[<h3>B.E.M. : Naming convention for CSS Classes</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ximvBviNqs1hW4L6mOVFcw.png" /></figure><h3>What is B.E.M?</h3><p>The <strong>Block, Element, Modifier (B.E.M.)</strong> methodology is a popular naming convention for classes in <strong>HTML </strong>and <strong>CSS</strong>. It is immensely useful in writing CSS that is easier to read, understand, and scale.<br>Here’s an example of what a UI developer code while following <strong>B.E.M.</strong> :</p><pre><strong>&lt;!-- HTML CODE --&gt;</strong><br>&lt;header class=&quot;header header--light&quot;&gt;</pre><pre> &lt;!--<br>  `btn` — block;<br>  `header__btn` — block element `header`;<br>  `btn--primary` — modifier.<br> --&gt;</pre><pre>&lt;button class=&quot;btn header__btn btn--primary button--active&quot;&gt;            &lt;/button&gt;<br>&lt;/header&gt;</pre><pre><strong>&lt;!-- SCSS CODE --&gt;</strong><br>.header{<br>   ...<br>   &amp;--header{<br>      ...<br>   }<br>   &amp;--btn{<br>      ...<br>   }<br>   .btn{<br>      ...<br>      &amp;--active{<br>          ...<br>      }<br>   }<br>}</pre><h3>Why should I use B.E.M.?</h3><p>BEM naming provides three specific benefits:</p><h4>1. It communicates the purpose of the class.</h4><p>If we are reading the markup instead of CSS, we should be able to quickly get an idea of whats the role of that given call (in the previous example we can see that .header — light is a modifier for block header, stating the header background has a light tone color).</p><h4>2. It communicates component structure</h4><pre>&lt;div class=&quot;gallery__carousel carousel&quot;&gt;</pre><p>I can tell from the above that I am looking at a div that is an element in a Gallery block. So I will be able to find this div ‘s positioning within the gallery in the gallery.scss file. Since this is also a Carousel block, I will be able to find the CSS for the Carousel block and the internal Carousel Elements in a carousel.scss file or some sort of global-blocks.scss file.</p><h4>3. Teamwork</h4><p>Having regular patterns of CSS usage enables many people to work together. Since BEM is helpful in component and design system (library of components) creation, it helps people work together on big projects.</p><h3>How It Works</h3><p>A BEM class name includes up to three parts.</p><ol><li>Block: The outermost parent element of the component is defined as the block.</li><li>Element: Inside of the component may be one or more children called elements.</li><li>Modifier: Either a block or element may have a variation signified by a modifier.</li></ol><p>If all three are used in a name it would look something like this:</p><p>[block]__[element]--[modifier]</p><p>After that brief introduction, let’s look at some specific examples.</p><p><strong>1: Navigation Bar</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fteam%2Fcss-tricks%2Fembed%2Fpreview%2FRNOMzJ%3Fheight%3D600%26slug-hash%3DRNOMzJ%26default-tabs%3Dhtml%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io&amp;display_name=CodePen&amp;url=https%3A%2F%2Fcodepen.io%2Fteam%2Fcss-tricks%2Fpen%2FRNOMzJ&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/a70985877fd5b72cddc7a188bb450665/href">https://medium.com/media/a70985877fd5b72cddc7a188bb450665/href</a></iframe><p><strong>2: Accordion Example</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fteam%2Fcss-tricks%2Fembed%2Fpreview%2FEaJEBZ%3Fheight%3D600%26slug-hash%3DEaJEBZ%26default-tabs%3Dhtml%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io&amp;display_name=CodePen&amp;url=https%3A%2F%2Fcodepen.io%2Fteam%2Fcss-tricks%2Fpen%2FEaJEBZ&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/d8c71ddd0514ca1dfa648ba7603cc689/href">https://medium.com/media/d8c71ddd0514ca1dfa648ba7603cc689/href</a></iframe><blockquote>Every coin has 2 sides, yes now it&#39;s time for the <strong>Pros </strong>and <strong>Cons </strong>of B.E.M.</blockquote><h4>Pros :</h4><ol><li>Fixes CSS inheritance and specificity issues</li><li>BEM provides a modular structure to your CSS project. Because of its unique naming scheme, we won’t run into conflicts with other CSS names.</li><li>Browsers evaluate CSS selectors right to left and BEM encourages developers to create a flat CSS structure with no nested selectors.</li></ol><h4>Cons :</h4><ol><li>The main hold back for BEM is that sometimes we wind up with very LONG names. However, if you are using SCSS/SASS precompiler, this may not be so bad because we can use nesting.</li><li>is known that BEM can bloat file sizes with the longer CSS class names, but this can easily be overcome by minifying and gzipping production code.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1e0cda5dc1d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>