<?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 Nikhil Nalande on Medium]]></title>
        <description><![CDATA[Stories by Nikhil Nalande on Medium]]></description>
        <link>https://medium.com/@nalandenv?source=rss-b516aa64002------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*bivzREv7hdRmSNwk</url>
            <title>Stories by Nikhil Nalande on Medium</title>
            <link>https://medium.com/@nalandenv?source=rss-b516aa64002------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 01:27:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nalandenv/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[How to create Netflix style input box]]></title>
            <link>https://medium.com/@nalandenv/how-to-create-netflix-style-input-box-62a38392b104?source=rss-b516aa64002------2</link>
            <guid isPermaLink="false">https://medium.com/p/62a38392b104</guid>
            <category><![CDATA[netflix]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[forms]]></category>
            <dc:creator><![CDATA[Nikhil Nalande]]></dc:creator>
            <pubDate>Thu, 26 Aug 2021 03:16:03 GMT</pubDate>
            <atom:updated>2021-08-26T17:43:46.009Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>In this short guide we are going to learn how to build Netflix style input box using vanilla HTML and CSS.</em></h4><h4>Introduction -</h4><p>Welcome to my guide to creating form input boxes in the Netflix style for your own projects. In this article, I’ll walk you through each step with the necessary code and screenshots to help you understand. You will have created a form as seen in the pictures below at the conclusion of this tutorial.</p><p><em>If you want to skip this tutorial and are only interested in the code then you can </em><a href="https://codepen.io/nalandenv/pen/MWmLZGE"><em>click here</em></a><em> to view it on codepen.io.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*dhF6fQmV0FSxwtGEHCHzEg.gif" /><figcaption>Working Demo</figcaption></figure><h4>Guide:</h4><p><em>Note-</em></p><ul><li>Basic understanding of HTML &amp; CSS so you can understand how this is panning out.</li><li>To eliminate some browser-specific style characteristics, I advocate using reset CSS while building web pages. <a href="https://stackoverflow.com/questions/11578819/css-reset-what-exactly-does-it-do">Click here</a> to learn more about it.</li></ul><h4>We will begin by creating a basic HTML form which contains:</h4><ul><li>The form element will be assigned the class “container”.</li><li>The h1 tag contains the heading “Sign In”.</li><li>The input with type <strong>text</strong> and its label are both included in a div with class “<em>form-element</em>”.</li><li>The input with type <strong>password</strong> and its label are both included in a div with class “<em>form-element</em>”.</li><li>The class “floating-label” is applied to all the labels.</li><li>A Sign-in button</li></ul><p><em>I’ve included the code snippet for a form that includes a heading, two input boxes, and a sign-in button below.</em></p><pre>&lt;form action=&quot;#&quot; class=&quot;container&quot;&gt;<br> &lt;h1&gt;Sign In&lt;/h1&gt;<br> &lt;div class=&quot;form-element&quot;&gt;<br>  &lt;input type=&quot;text&quot; name=&quot;username&quot; id=&quot;username&quot; required /&gt;<br>  &lt;label class=&quot;floating-label&quot; for=&quot;username&quot;&gt;Email or Phone   Number&lt;/label &gt;<br> &lt;/div&gt;<br> &lt;div class=&quot;form-element&quot;&gt;<br>  &lt;input type=&quot;password&quot; name=&quot;password&quot; id=&quot;password&quot; required /&gt;<br>  &lt;label class=&quot;floating-label&quot; for=&quot;password&quot;&gt;Password&lt;/label&gt;<br> &lt;/div&gt;<br> &lt;button class=&quot;btn-sign-in&quot;&gt;Sign In&lt;/button&gt;<br>&lt;/form&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/376/1*zqQ--Qd00nWfExI0XamjSQ.png" /><figcaption>Form without reset CSS</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*iAwp5_7JFQd8g2kmtABwYA.png" /><figcaption>Form with reset CSS</figcaption></figure><p>We’ll import the <strong>Roboto</strong> font from Google and apply it to the body element, with the default font size set to <strong>16px. <br></strong><em>*You can copy the below code for importing and applying the font or you can pick font of your choice.<br>*Make sure the code below is at the top of your CSS file.</em></p><pre>@import url(https://fonts.googleapis.com/css?family=Roboto:100,regular,italic,500,700);<br>body {<br> font-family: “Roboto”;<br> font-size: 16px;<br>}</pre><p>We’ll then add CSS attributes to the container that contains the form components.</p><ul><li>Set the display to <em>block.</em></li><li>We’ve set the width at 450px, but you’re free to adjust it to whatever you’d like.</li><li>To align the container to the center of the page, margin auto is applied to the sides, and 50 px is applied to top and bottom.</li><li>Padding of 16px is applied on all sides.</li><li>A border-radius of 4px is used to round the edges of the container.</li><li>This container’s background-color is a shade of black with color set to white for text.</li><li>Position is set to <em>relative</em>, as we’ll need to utilize absolute position for labels in next section.</li></ul><pre>.container {<br>position: relative;<br>display: block;<br>width: 450px;<br>margin: 50px auto;<br>padding: 16px;<br>background-color: #292929;<br>color: #ffffff;<br>border-radius: 4px;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*R-uAo4XLl_csNhH9LiQniA.png" /><figcaption>Form after applying styles to container</figcaption></figure><h4>Now we’ll work on the heading and form element which is the parent div of input and label.</h4><ul><li>The selector “.container h1” selects all the elements with h1 tag inside of div with class “container”.</li><li>The font size is set to 2em, which is twice the existing font size.</li><li>The bottom margin is set to 28px, however you can adjust it if you like.</li></ul><pre>Attached below is a code snippet for styling h1 tag:<br>.container h1 {<br> font-size: 2em;<br> font-weight: 700;<br> margin-bottom: 28px;<br>}</pre><ul><li>The selector “.container .form-element” selects all the elements with class “form-element” inside of div with class “container”</li><li>Position is set to relative for the labels with absolute position attribute.</li><li>The div will be centered inside the parent element when margin is set to “0 auto”.</li><li>To provide space below the form element, the bottom padding is set to 16px.</li></ul><pre>.container .form-element {<br> position: relative;<br> margin: 0 auto;<br> padding-bottom: 16px;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*cjJ9VCny4vbIihrqBU6y3g.png" /><figcaption>h1 and form-element styled</figcaption></figure><h4>Next up is the input box for email/phone number and password.</h4><ul><li>The selector “.form-element input” selects all input boxes within a div with the class “form-element.”</li><li>The box-sizing property is set to border-box to prevent the items within it from overflowing into parent element.</li><li>The width is set to 100% so input will occupy all the available width.</li><li>Font size is set to 16px, because input won’t inherit the parent’s font size.</li><li>Padding applied to the Top, Right, Bottom, and Left is defined as “padding: 16px 20px 0 20px.”</li><li>To accommodate a floating label, the height is set to 50px.</li><li>To improve immersion, the border has been removed.</li><li>For round edges, the border radius is set to 5px.</li><li>Outline is set to none to disable the default outline used by browsers when input is focused.</li><li>The background color is a shade of grey, while the input text color is white.</li></ul><pre>.form-element input {<br> box-sizing: border-box;<br> width: 100%;<br> font-family: inherit;<br> padding: 16px 20px 0 20px;<br> height: 50px;<br> font-size: 16px;<br> border: none;<br> border-radius: 5px;<br> outline: none;<br> background-color: #444444;<br> color: #ffffff;<br>}</pre><p><em>Note -<br></em>*Make sure replace input with input[type=”text”]/input[type=”password”] if you want to use multiple input types inside the same container.<br>*This floating label method will not work for input type email. Use text instead of email and validate using regular expression.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*mXLOXA_7Y7TVhitNZdUYow.png" /><figcaption>Form without floating label</figcaption></figure><h4>Next, we’ll begin working on labels for the input boxes, which will also serve as placeholders.</h4><ul><li>The box-sizing property is set to border-box to prevent the items within it from overflowing into parent element.</li><li>Width is set to 100% so the label fills entire width of the parent element.</li><li>The position is set to absolute so that the label appears on top of the input field.</li><li>The label’s <strong>top</strong> is set to <strong>25%</strong> to keep it vertically centered, and the <strong>left</strong> is set to <strong>20px</strong> to keep it aligned with the input text in the input field.</li><li>For improved visibility, I’ve increased the text size to 18px.</li><li>Cursor is set to text, because we don’t want the it to be an arrow when hovering over the label.</li><li>For a less contrasty look, the color has been set to a shade of gray.</li></ul><pre>.floating-label {<br> box-sizing: border-box;<br> width: 100%;<br> position: absolute;<br> top: 25%;<br> left: 20px;<br> font-size: 18px;<br> cursor: text;<br> color: #8c8c8c;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*5jnBcfPCtmBXkm7arzi9xw.png" /><figcaption>Form with floating label</figcaption></figure><h4>Now we’ll focus on the sign-in button:</h4><ul><li>Width is set to 100% to fill the parent container’s entire width.</li><li>To match the height of the input field, the height of button is set to 50px.</li><li>For extra space between the input and the button, the top margin is 24px; feel free to change it.</li><li>To preserve uniformity, the font size is 18px, and the weight is 700 to make it bold.</li><li>A border-radius of 5px is used to round the edges of the button.</li><li>Border is set to none to remove the button’s default border.</li><li>To avoid inheriting the grey color of prior elements, color is set to white.</li><li>The button’s background color is a shade of red similar to that used by Netflix.</li></ul><pre>.btn {<br> width: 100%;<br> height: 50px;<br> margin-top: 24px;<br> cursor: pointer;<br> font-size: 18px;<br> font-weight: 700;<br> border-radius: 5px;<br> border: none;<br> color: #ffffff;<br> background-color: #e50914;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*HVJcTzfciBF7LGrRnm4SqA.png" /><figcaption>Form without dynamic floating label</figcaption></figure><h4>We’ve finally reached the end, now we’ll concentrate on moving the label to the top when the input has focus:</h4><ul><li>We first check to see whether the <strong>input has focus</strong>, then we check to see <strong>if it is valid</strong>. If either of these criteria is fulfilled, we apply new attributes to the label to move it to the top of the input field.</li><li>We reduce its font size to 11px and set its position to top 7 since we don’t want it to overlap the input content.</li><li>If the input is focused or has content, the label will remain at the top thanks to the aforementioned validations. Otherwise, when the input is out of focus and there is no text content in it, it will revert to its normal location.</li></ul><pre>input:focus ~ .floating-label,<br>input:valid ~ .floating-label {<br> font-size: 11px;<br> top: 7px;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/534/1*sZ6xPsuIGv60GxLSZrKcsA.png" /><figcaption>Final form with working floating label</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62a38392b104" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>