<?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 Anas Ansari on Medium]]></title>
        <description><![CDATA[Stories by Anas Ansari on Medium]]></description>
        <link>https://medium.com/@anasansari157?source=rss-cd34785a845f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*XUo4tkHh0tWzjK7PWHBvdA.jpeg</url>
            <title>Stories by Anas Ansari on Medium</title>
            <link>https://medium.com/@anasansari157?source=rss-cd34785a845f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 17:09:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anasansari157/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[Nokogiri Error on Installing Rails]]></title>
            <link>https://medium.com/@anasansari157/nokogiri-error-on-installing-rails-c0b2cdf95e1b?source=rss-cd34785a845f------2</link>
            <guid isPermaLink="false">https://medium.com/p/c0b2cdf95e1b</guid>
            <category><![CDATA[ruby-on-rails-development]]></category>
            <category><![CDATA[installation]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[installation-failed]]></category>
            <category><![CDATA[error]]></category>
            <dc:creator><![CDATA[Anas Ansari]]></dc:creator>
            <pubDate>Thu, 06 Aug 2020 09:48:41 GMT</pubDate>
            <atom:updated>2020-08-06T09:48:41.030Z</atom:updated>
            <content:encoded><![CDATA[<p>How I solved Nokogiri error and installed Ruby on Rails on Fedora OS</p><p><strong>Note: </strong><em>This post does not discuss about what these problems were, rather it provides solution to the problems which I faced.</em></p><p>I was following a tutorial, Pragmatic Studio Rails Course. In that exercise, it asks you to make a rails app.</p><p>Going through the tutorial, I did rails new eventz but it could not install all the packages present in the Gemfile. It always showed this error:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Mf4BMK-9jPIu909n-YNSg.png" /><figcaption>Problems with Nokogiri</figcaption></figure><p>The initial packages couldn’t be installed so I tried bundle install --path vendor/bundle but that too resulted in the error.</p><p>No matter what solution I use it always ended up in this error:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qcocQ8UQOkohgdb-Ur1C5A.png" /><figcaption>Again, Nokogiri Error: Failed to build gem native extension.</figcaption></figure><h3>The Solution</h3><p>After a lot of frustration and attempts, I got the something on <a href="https://developer.fedoraproject.org/tech/languages/ruby/ror-installation.html">FedoraProject</a>.</p><p>The problem was: I did not have the proper files required to bundle things together.</p><h4><strong>Commands that fixed this error:</strong></h4><pre>$ sudo dnf group install &quot;C Development Tools and Libraries&quot;<br>$ sudo dnf install ruby-devel zlib-devel<br>$ gem install rails<br>$ bundle install</pre><p>If you get sqlite3 error that means you’re on the right track</p><p>You have to install sqlite3 header packages, you can get the package <a href="https://pkgs.org/download/sqlite-devel">here</a>.</p><p>This command installs the files.</p><pre>dnf install sqlite-devel</pre><p>then generate bundle</p><pre>bundle install</pre><p>And, voila! You are good to go. Run your server using:</p><pre>rails s</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y_JH8kPM2YzGjgjKX51kew.png" /><figcaption>The server successfully started on port 3000</figcaption></figure><p>Now, your app starts at <a href="http://localhost:3000/">http://localhost:3000</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uS145kJDdtkaC_WBGnyFTA.png" /></figure><p>I wasted my 20+ hours on this problem. I hope no one else has to do that.</p><p>If you found something wrong with the article or something doesn&#39;t work or maybe you found another solution, please mention them in the responses so that don&#39;t have to go through things that you have.</p><p>Thank you for your time.</p><p>I’m Anas Ansari.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0b2cdf95e1b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to DOM]]></title>
            <link>https://medium.com/@anasansari157/introduction-to-dom-6a84befb2884?source=rss-cd34785a845f------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a84befb2884</guid>
            <category><![CDATA[dom]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Anas Ansari]]></dc:creator>
            <pubDate>Sun, 12 Jan 2020 18:56:48 GMT</pubDate>
            <atom:updated>2020-01-12T18:59:30.663Z</atom:updated>
            <content:encoded><![CDATA[<h4>What is DOM and Why you should care?</h4><p>A few days back, I tweeted:</p><h3>Anas Ansari on Twitter</h3><p>For me, the difference between Hating and Loving JavaScript is: DOM #AltCampus #100DaysOfCode https://t.co/FehDy1XCqm</p><p>The difficult part when you start to learn JavaScript after progressing over HTML and CSS is that you get so hooked to visual impressions that sometimes things don’t make sense to you. For instance, when you write HTML code or add styles to it you can see in your browser that the styles you applied have effect in the browser window. And that helps a lot to clear our concepts about what styles are performing what impressions on the page.</p><p>But as soon as you climb on to learn JavaScript, things start to fall apart because we don’t understand how the variables, the loops, the arrays, the functions I’m learning how it is gonna help in Front-End or how I’m gonna implement those things in the browser. That’s where I started hating JavaScript until I met a faithful friend called DOM. And, Life is getting better now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*os6bLCkayRRCYp8UTbICxw.jpeg" /><figcaption><a href="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTKIWSSU3dxpMbGxPu8qeoH9bl__wWRvqXjUB-88MPZ3_0-mxMZ1Q&amp;s">https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTKIWSSU3dxpMbGxPu8qeoH9bl__wWRvqXjUB-88MPZ3_0-mxMZ1Q&amp;s</a></figcaption></figure><h3>So what is DOM?</h3><p>At the most basic level, a website consists of an HTML and CSS document. The browser creates a representation of that document known as Document Object Model (DOM). This document enables Javascript to <strong>access </strong>and <strong>manipulate</strong> the elements and styles of a website and also add functionality to our page.</p><p>The model is built in a tree structure of objects. Everything which is an element in HTML is an object in DOM.</p><p>For example,</p><p>In HTML:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LCkG2wsyXLaWIpnggCJU-w.png" /></figure><p>In DOM, the above code is represented as a DOM tree:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*5XVbVjjoFmCM2ZOwuJcNow.png" /></figure><h3>DOM Document</h3><p>The DOM Document is the owner of all other objects in your webpage. That means if you want to access any object on your webpage you always have to start with the document. It also contains many important properties and methods that enable us to access and modify our website. For instance,</p><pre>document.body</pre><p>Outputs the whole body element with all its content on the console:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*n93MYCF84sgCiCRFwIIMDQ.png" /></figure><h3>Accessing the elements</h3><p>To apply styles or functionality to an element using JS, we need to first select that element and then do what we have to do to that element. For accessing, DOM provides many inbuilt functions that we can use to select that element.</p><h4>getElementBy</h4><p>The<strong> getElementBy[Id|ClassName|TagName]()</strong> method returns the element that has the ID attribute, Class attribute or Tag attribute with the specified value. For eg,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*ADGjVHipXMgtVmJCkwEJTQ.png" /></figure><p>This method is one of the most common methods in the HTML DOM and is used almost every time you want to manipulate, or get info from, an element on your document.</p><h4>getElementsBy</h4><p>The<strong> getElementsBy[ClassName|TagName]()</strong> method returns all the elements that have the Class attribute or Tag attribute with the specified value in node form. For eg,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Dfixq5pZmCtDSHqY9TmIQ.png" /></figure><h4>querySelector &amp; querySelectorAll</h4><p><strong>document.querySelector() </strong>returns the first element within the document that matches the specified selector, or group of selectors. If no matches are found, null is returned. We don’t have to use different methods for different tags.</p><p><strong>document.querySelectorAll()</strong> returns a Node List representing a list of the document’s elements that match the specified group of selectors. If no matches are found, null is returned.</p><p>Examples of <strong>querySelector() </strong>and <strong>querySelectorAll():</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ICGxCrV5D5a2Boer693Evg.png" /></figure><h3>Manipulating the elements</h3><p>The HTML DOM allows us to change the content and style of an HTML element by changing its properties.</p><h4>innerHTML</h4><p>The innerHTML property can be used to change the content of an HTML element.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qqEU_RNYWqI8Jebq8ex-lQ.png" /></figure><p>In this example, we get the element with an id of heading and set the inner content to “Hello World!”.</p><p>InnerHTML can also be used to put tags in another tag:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IP2Qk3ou-uaBVvcMZLIZbQ.png" /></figure><h4>Changing the style</h4><p>To change the style of an HTML element we need to change the style property of our elements. Here is the syntax for changing the border style on an element:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TkiBlCp5p-PB7N8B-jtoPA.png" /></figure><p>We need to write the in camelcase instead of the normal CSS property name. In this example we used borderBottom instead of border-bottom.</p><p>That’s it for now. It might be overwhelming if you’re learning all this for the first time.</p><p>Isn’t JavaScript going to be interesting now? Yeah, I hope so too.</p><p><strong>Let’s Be Short And Be Consistent.</strong></p><p>In case we are meeting for the first time, hello. My name is <strong>Anas Ansari</strong>. I am learning Full Stack Development at <a href="http://altcampus.io/">AltCampus</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a84befb2884" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Responsive Layout using Media Queries]]></title>
            <link>https://medium.com/@anasansari157/responsive-layout-using-media-queries-94ec2c983fd3?source=rss-cd34785a845f------2</link>
            <guid isPermaLink="false">https://medium.com/p/94ec2c983fd3</guid>
            <category><![CDATA[media-queries]]></category>
            <category><![CDATA[mobile-first]]></category>
            <category><![CDATA[html-css]]></category>
            <category><![CDATA[responsive-design]]></category>
            <dc:creator><![CDATA[Anas Ansari]]></dc:creator>
            <pubDate>Thu, 05 Dec 2019 18:09:41 GMT</pubDate>
            <atom:updated>2019-12-05T18:09:41.828Z</atom:updated>
            <content:encoded><![CDATA[<h4>Making the website responsive using the Responsive Web Design ruleset.</h4><p>Back when the internet was getting popular in the ’90s, the websites were designed just for computers with a few properties that can be used at that time. The technology has advanced a lot, heretofore.<br>Since the ’00s, with the contrivance of mobile devices and the internet becoming faster day by day, a large portion of internet consumers has shifted to using mobile devices as their primary convenience to access the World Wide Web. As of now,</p><blockquote>WARC estimates that around 2 billion people currently access the <strong>internet</strong> via only their smartphone.</blockquote><p>That&#39;s <strong>51%</strong> of the people accessing internet on mobile devices. Now, the internet has been shifting towards the mobility of devices and so are the content for the devices to access.</p><p>While this shift is emerging on, many websites are built to target mobile users too, as well as computer users. Hence, there emerged the concept of making the website <strong>responsive</strong>, i.e, accessible on various devices of different screen ratios.</p><p><strong>Responsive web design </strong>refers to the idea that your website should display equally well in everything from widescreen monitors to mobile phones. It’s an approach to web design and development that eliminates the distinction between the mobile-friendly version of your website and its desktop counterpart. With responsive design, they’re the same thing.</p><p>The term “responsive web design” was coined by Ethan Marcotte, a web designer/developer, in May 2010 in an <a href="https://alistapart.com/article/responsive-web-design/">article</a>.</p><h3>Media Queries</h3><p>To make a website responsive we use <strong>media queries. </strong>Media queries are nothing but a way of telling the browser what CSS styles to show at a particular state. They tell the browser that it should ignore or apply certain rules depending on the user’s device.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XwozbaWlFKOWudhAtHcKpw.png" /><figcaption><a href="https://internetingishard.com/html-and-css/responsive-design/">https://internetingishard.com/html-and-css/responsive-design/</a></figcaption></figure><p>For eg, if the website is opened on smaller devices, like mobile phones or smartphones it would show the contents of a website in a specific and different way than the same website being opened on the desktop.</p><h4>Why do we wanna do that, i.e, to show different styles on different screen-size? Doesn’t that just increase the time and effort of writing more code?</h4><p>Good question. Well, the reason is:</p><ul><li>It helps our content in a more readable and ecstatic way. You don’t want to show the desktop-sized image(1400px wide) on a 320px wide screen of a mobile. Do you?</li><li>It helps allow us to show content and layout in a way that would be desirable for the user.</li><li>Wouldn’t it be too much task for a browser of Mobile phone to load those big files that mobile-users likely won&#39;t be able to understand? Oh, and let&#39;s not talk about the bandwidth it would consume.</li></ul><h3>How to use media queries?</h3><p>A media query is composed of an optional <em>media type</em> and any number of <em>media feature</em> expressions. Multiple queries can be combined in various ways by using <em>logical operators</em>. Media queries are case-insensitive.</p><p>Syntax of a media query case:</p><pre>@media only screen and (max-width: 600px) {<br>  body {<br>    background-color: lightblue;<br>  }<br>}</pre><p>This changes the background color of the webpage to light-blue only when the width of the window is less than 600px.</p><p>Let&#39;s break our code down to understand things better:</p><pre>@media</pre><p>It tells the browser that “Hey browser, there is a condition ahead. You have to run the styles only if a certain condition satisfies true.</p><pre>@media only</pre><p><strong>only </strong>is a <em>logical operator </em>used to apply a style only if an entire query matches. The <em>logical operators</em> <strong>not,</strong> <strong>and </strong>and <strong>only</strong> can be used to compose a complex media query. You can also combine multiple media queries into a single rule by separating them with commas.</p><pre>@media only screen</pre><p>The <strong>screen </strong>is a <em>media type. Media types</em> describe the general category of a device. Except when using the <strong>not </strong>or <strong>only </strong>logical operators, the media type is optional and the <strong>all </strong>type will be implied.</p><pre>@media only screen and</pre><p>Explained earlier, already. It is a logical operator. It is used to define two conditions. The rules take place only if both conditions are satisfied.</p><pre>@media only screen and (max-width: 600px)</pre><p>The <strong>max-width </strong>called <strong>media features. </strong>This<strong> </strong>describes the specific characteristics of a given user agent, output device, or environment. There are many media features like, color, aspect ratio, max-width, orientation. Max and mins are more common, though.</p><pre>@media only screen and (max-width: 600px) {<br>....<br>}</pre><p>The first and last {} implies that it contains styles that are to be applied when the afore-mentioned condition is fulfilled.</p><pre>@media only screen and (max-width: 600px) {<br>  body {<br>    background-color: lightblue;<br>  }<br>}</pre><p>Well, there is no need to explain what the code under those curly brackets doing. If you don’t understand the inner lines, I don’t think that you would understand the media queries.</p><p>Hey, if you don’t understand those lines, you still have come to the right place. I have written some articles explaining those basics, too. You might wanna read them <a href="https://medium.com/@anasansari157">here</a>.</p><p>That’d be it for now. We will take a look over more of it later. Let&#39;s not bite what we can’t chew because…</p><p><strong>It is better to lay one brick a day than building the whole wall but puny.</strong></p><p>Anyway, in case we are meeting for the first time, hello. My name is Anas Ansari. I write about <a href="https://medium.com/@anasansari157">stuff that I understand</a>. I’m learning Full Stack Development at <a href="http://altcamous.io/">AltCampus</a>.</p><p>Thanks for your time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94ec2c983fd3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hop on Flexbox]]></title>
            <link>https://medium.com/@anasansari157/hop-on-flexbox-d01c0a6b73bb?source=rss-cd34785a845f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d01c0a6b73bb</guid>
            <category><![CDATA[positioning]]></category>
            <category><![CDATA[flexbox-froggy]]></category>
            <category><![CDATA[flexbox]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Anas Ansari]]></dc:creator>
            <pubDate>Sun, 01 Dec 2019 20:36:22 GMT</pubDate>
            <atom:updated>2019-12-01T20:36:22.275Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to learn flexbox once and for all.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*P-REWru5xmVpf1XFQznasg.png" /></figure><p>Flexbox was the only reason when I thought that CSS isn’t my cup of tea and thereby, I will never be able to learn Web Development. But now, when I am familiar with the basics and its core concepts, things have become easy now. When I think about it- what required, to learn flexbox better, was to spend more time with it.</p><p>I have gone through many tutorials to understand Flexbox. One good way to learn flexbox is to stick to one tutorial of your choice (what you understand well and which you find connected with you). And start doing examples, exploring code pens about flexbox and Yeah, you can<a href="https://dev.to/devmount/8-games-to-learn-css-the-fun-way-4e0f"> play games to learn CSS</a>, too. That’s exactly what we are going to do, here.</p><h3>First, Brush-up on the basics of Flexbox</h3><p>Flexbox was designed as a one-dimensional layout model and also to align things easily and distribute unused spaces evenly around or between contents.</p><h4>Axes of Flexbox</h4><p>Everything we do with flexbox refers to axes. There are two axes in Flexbox Model- the <strong>main-axis</strong> and the <strong>cross-axis.</strong></p><p>The <strong>main-axis </strong>is defined by <strong>flex-direction</strong> which has four possible values:</p><ul><li>row</li><li>row-reverse</li><li>column</li><li>column-reverse</li></ul><p>If you use row or row-reverse, the main-axis will be in the row direction (horizontally) and our elements will become inline.</p><p>If you use column or column-reverse, the main-axis will be in the column direction (vertically) and our elements will become block-level.</p><h4>Flexbox Container and Flexbox Items</h4><p>In the Flexbox Model, we apply a few properties on the flex-container (parent) and few on the flex-items (children).</p><p>To start using properties of elements, we give the parent <strong>display: flex </strong>and then only we can use all the properties related to flexbox.</p><p>Let&#39;s see what these properties are:-</p><p><strong>Flex properties that can be applied to the parent element:</strong></p><ul><li>Display</li><li>Flex Direction</li><li>Flex Wrap</li><li>Flex Flow</li><li>Justify Content</li><li>Align Items</li><li>Align Content</li></ul><p><strong>Flex properties that can be applied to the children:</strong></p><ul><li>Order</li><li>Flex Grow</li><li>Flex Shrink</li><li>Flex Basis</li><li>Flex</li><li>Align Self</li></ul><p>There’s a better way to remember these properties and that is by using them. And to use, we are going to solve some puzzle games (the ones I told you earlier?)</p><blockquote>One such game is <a href="https://flexboxfroggy.com/">Flexbox Froggy</a>. It is one of the better ways to remember the properties and their use.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*P-REWru5xmVpf1XFQznasg.png" /></figure><p>In this game, we have to guide the frog to the lilypad. So let&#39;s start solving them and have fun:</p><blockquote>If you wanna slove together, it is recommended to open <a href="https://flexboxfroggy.com/">Flexbox Froggy</a> in the new tab and code along with me.</blockquote><p>SPOILERS: This article also contains the right answers to solve the puzzle. It is recommended to solve the levels before you see <strong>ANSWER AHEAD.</strong></p><h3>LEVEL 1</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*A6YYBxVVNWGWlPTOf41CAA.png" /><figcaption><a href="https://flexboxfroggy.com/">https://flexboxfroggy.com/</a></figcaption></figure><p>In this level, we are going to guide the frog to the right lilypad by using the <strong>justify-content</strong> property, which aligns items horizontally and accepts the following values:</p><ul><li><strong>flex-start</strong>: Items align to the left side of the container.</li><li><strong>flex-end</strong>: Items align to the right side of the container.</li><li><strong>center</strong>: Items align at the center of the container.</li><li><strong>space-between</strong>: Items display with equal spacing between them.</li><li><strong>space-around</strong>: Items display with equal spacing around them.</li></ul><p><strong>ANSWER AHEAD</strong></p><p>To solve this, we will use</p><p><strong>justify-content: flex-end;</strong></p><p>This pushes the frog to the right.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*I8WqTftlrEbJ17UQA02Inw.png" /><figcaption><a href="https://flexboxfroggy.com/">https://flexboxfroggy.com/</a></figcaption></figure><h3>LEVEL 2</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*R8Ov4X8Gs746H5bMCHYFnA.png" /></figure><p>We have to use <strong>justify-content</strong> again to help these frogs get to their lilypads.</p><p><strong>ANSWER AHEAD</strong></p><p>To solve this, we will use</p><p><strong>justify-content: center;</strong></p><p>This pushes the frogs to the center.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/1*QOSNn4QzV7YUDQrQamQBZw.png" /><figcaption><a href="https://flexboxfroggy.com/">https://flexboxfroggy.com/</a></figcaption></figure><h3>LEVEL 3</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*tZFsLJhyZznqBuKepdF3eA.png" /><figcaption><a href="https://flexboxfroggy.com/">https://flexboxfroggy.com/</a></figcaption></figure><p>We have to use <strong>justify-content</strong> again to help these frogs get to their lilypads.</p><p><strong>ANSWER AHEAD</strong></p><p>To solve this, we will use</p><p><strong>justify-content: space-around;</strong></p><p>This pushes the frogs to their respective lilypads.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*GqipNf5YM8ipY-j5riIjqA.png" /><figcaption><a href="https://flexboxfroggy.com/">https://flexboxfroggy.com/</a></figcaption></figure><h3>LEVEL 4</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*HTIVza_RrIk3e2XqpxmYXA.png" /></figure><p>We have to use <strong>justify-content</strong>. This time, the lilypads have equal spacing between them.</p><p><strong>ANSWER AHEAD</strong></p><p>To solve this, we will use</p><p><strong>justify-content: space-between;</strong></p><p>This pushes the frogs to their respective lilypads.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*l2tXE5zHzm53VxkYWZbRBA.png" /><figcaption><a href="https://flexboxfroggy.com/">https://flexboxfroggy.com/</a></figcaption></figure><h3>LEVEL 5</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*F0NtWplgEvjEQd2DG3OTUg.png" /></figure><p>Now we have to use <strong>align-items</strong> to help the frogs get to the bottom of the pond. This CSS property aligns items vertically and accepts the following values:</p><ul><li><strong>flex-start</strong>: Items align to the top of the container.</li><li><strong>flex-end</strong>: Items align to the bottom of the container.</li><li><strong>center</strong>: Items align at the vertical center of the container.</li><li><strong>baseline</strong>: Items display at the baseline of the container.</li><li><strong>stretch</strong>: Items are stretched to fit the container.</li></ul><p><strong>ANSWER AHEAD</strong></p><p>To solve this, we will use</p><p><strong>align-items: flex-end;</strong></p><p>This pushes the frogs to bottom.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*5BeHaH1GCX-NwjIxC_NvQg.png" /></figure><h3>LEVEL 6</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*OiagytCj0PabKKP55nBEBg.png" /></figure><p>Now we have to lead the frog to the center of the pond using a combination of <strong>justify-content</strong> and <strong>align-items</strong>.</p><p><strong>ANSWER AHEAD</strong></p><p>To solve this, we will use</p><pre><strong>align-items: center;<br>justify-content: center;</strong> </pre><p>This pushes the frogs to center. We use this property very often when we want to center things in CSS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*FKjRdkDiN8W1vZXeWs_27A.png" /></figure><h3>LEVEL 7</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*GzocCfzr4-JStyBaqL-Nzg.png" /></figure><p>The frogs need to cross the pond again, this time for some lilypads with plenty of space around them. Using a combination of <strong>justify-content</strong> and <strong>align-items</strong>.</p><p><strong>ANSWER AHEAD</strong></p><p>To solve this, we will use</p><pre>align-items: flex-end;<br>justify-content: space-around;</pre><p>This pushes the frogs to bottom and with space between and around them also.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*i-IByZbgEpG-iZRIhP5rhg.png" /></figure><h3>LEVEL 8</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*pb6BLzHdMgxkQcOKxwaOEQ.png" /></figure><p>The frogs need to get in the same order as their lilypads using <strong>flex-direction</strong>. This CSS property defines the direction items are placed in the container, and accepts the following values:</p><ul><li><strong>row</strong>: Items are placed the same as the text direction.</li><li><strong>row-reverse</strong>: Items are placed opposite to the text direction.</li><li><strong>column</strong>: Items are placed top to bottom.</li><li><strong>column-reverse</strong>: Items are placed bottom to top.</li></ul><p><strong>ANSWER AHEAD</strong></p><p>To solve this, we will use <strong>flex-direction: row-reverse;</strong> This reverses the frogs’ direction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*ED3pj6oT331UjtZnA1oHyw.png" /></figure><h3>LEVEL 9</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*hQeK5Jk1ZbPvQRuHc24nvg.png" /></figure><p>In this puzzle, help the frogs find their column of lilypads using <strong>flex-direction</strong>.</p><p><strong>ANSWER AHEAD</strong></p><p>To solve this, we will use</p><p><strong>flex-direction: column</strong>;</p><p>This changes the frog direction to the column.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*9_JWDvYyThanwRFHFjCARQ.png" /></figure><h3>LEVEL 10</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*esqBmlX542HM8X3yXYvozQ.png" /></figure><p>Now, we have to help the frogs get to their own lilypads. Although they seem close, it will take both <strong>flex-direction</strong> and <strong>justify-content</strong> to get them there.</p><p><strong>ANSWER AHEAD</strong></p><p>To solve this, we will use</p><pre>flex-direction: row-reverse;<br>justify-content: flex-end;</pre><p>This helps the frogs to jump on their respective lilypads.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*AE7yx2ntUtTIAsyePYL11Q.png" /></figure><h3>LEVEL 11</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*XBQfvx70r6sj5GS2XLDuZQ.png" /></figure><p>Help the frogs find their lilypads using <strong>flex-direction</strong> and <strong>justify-content</strong>.</p><p>Notice that when the flex-direction is a column, <strong>justify-content</strong> changes to the vertical and <strong>align-items</strong> to the horizontal.</p><p><strong>ANSWER AHEAD</strong></p><p>To solve this, we will use</p><pre>flex-direction: column;<br>justify-content: flex-end;</pre><p>This aligns the frogs vertically and to the bottom.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*xzh0KvUaXKpLkk_dzxxYYQ.png" /></figure><h3>LEVEL 12</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*RjOWftWI6isnj0eo8wxw-w.png" /></figure><p>We have to help the frogs to find their respective lilypads.</p><p><strong>ANSWER AHEAD</strong></p><p>To solve this, we will use</p><pre>flex-direction: column-reverse;<br>justify-content: space-between;</pre><p>This reverses their initial position vertically a<strong>nd justify-content</strong> applies space between them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*gjI-tXgfe8U2WX_xPaz5eA.png" /></figure><p>WOW!! You did it, man.</p><p>There are 24 puzzles in total, we have reached Level 12, so far and the article has become so long, isn’t it? And I hate reading long articles and I assume you too. That&#39;s why I want to solve the rest of the puzzles in the next article. Till then if you wanna solve some of the puzzles, sure, please do that. And if you stuck in any one of them, you know that I’m here, right?</p><p>It was really fun solving these exercises. If you have any doubt about anything you can refer to these good articles written by some of my friends and some tutorial sites:</p><ul><li><a href="https://css-tricks.com/snippets/css/a-guide-to-flexbox/">A Complete Guide to Flexbox | CSS-Tricks</a></li><li><a href="https://medium.com/@bim240/flexbox-altcampus-a9627fab44ff?source=---------2------------------">Flexbox(AltCampus)</a> by Bimlendu</li><li><a href="https://medium.com/@sahil.kapoor440/css-flexbox-a-developers-rejoice-to-placing-elements-on-a-website-29efaa3aa9df?source=search_post---------0">CSS Flexbox: A web developer’s delight to positioning elements</a> by Sahil</li><li><a href="https://medium.com/@jaybhoyar1997/flexbox-the-saviour-34cade68360f?source=---------2------------------">FlexBox — The Saviour</a> by Jay Bhoyar</li></ul><p>Anyway, in case we are meeting for the first time, hello. My name is Anas Ansari. I write about <a href="https://medium.com/@anasansari157">stuff that I understand</a>. I’m learning Full Stack Development at <a href="http://altcamous.io/">AltCampus</a>.</p><p>Thanks for your time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d01c0a6b73bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to survive without Floats]]></title>
            <link>https://medium.com/@anasansari157/how-to-survive-without-floats-d2110f5af9c2?source=rss-cd34785a845f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d2110f5af9c2</guid>
            <category><![CDATA[position]]></category>
            <category><![CDATA[positioning]]></category>
            <category><![CDATA[html-css]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Anas Ansari]]></dc:creator>
            <pubDate>Thu, 28 Nov 2019 06:27:51 GMT</pubDate>
            <atom:updated>2019-11-28T06:27:51.887Z</atom:updated>
            <content:encoded><![CDATA[<h4>What are other options in the box-model apart from using floats?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*IXbRvoiY2IfD_5LXnPpWLg.png" /></figure><p>Well. Well. Well. If you’re following me from the start of this series, you might know that we have learned about <strong>floats, </strong>previously. We liked the way it wraps images or anything around the content beautifully. It takes us away from the boring box-model which is one-directional to floating our contents two-directional.</p><p>But <strong>floats </strong>have some drawbacks too like <strong>clearing</strong> the element coming after it to align them properly otherwise it leads to some catastrophic and unwanted changes in our layout. Sometimes the <strong>clearing </strong>doesn’t work so we have to use other techniques like <strong>containing the floats, hiding the overflow</strong>. See:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*5rEP0K0wzkXYRUYXlI_-ig.png" /><figcaption><a href="https://css-tricks.com/all-about-floats/">https://css-tricks.com/all-about-floats/</a></figcaption></figure><p>One more problem is the unnatural spacing between the two parents and one floated element:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*0rOq-qgOmJ0rg1prEdmwzw.png" /><figcaption><a href="https://css-tricks.com/all-about-floats/">https://css-tricks.com/all-about-floats/</a></figcaption></figure><p>One more limitation we have in <strong>floats </strong>is that we can only float elements in two directions only i.e. either left or right. But what if we want to put an element on a specific place of the webpage. For eg, how would we put a box on the top-right corner of the viewport(you know viewport, right?). Or how do we make a “back-to-top” button that sticks to the screen even if we scroll down with floats?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZBrX3OtV4aQSIFhnNr94yw.png" /><figcaption><a href="https://internetingishard.com/html-and-css/advanced-positioning/absolute-positioning-screenshot-641ad7.png">https://internetingishard.com/html-and-css/advanced-positioning/absolute-positioning-screenshot-641ad7.png</a></figcaption></figure><h3>Here comes the position</h3><p>This is where <strong>position </strong>property comes in. It lets you position an element precisely on the webpage. Position property in CSS uniquely positions the elements anywhere on our page or window.</p><p>There are mainly 3 kinds of positioning in CSS. Oh wait, there are 4! With positioning property set to our element that we want to position, we get 4 more box-offset properties (top, right, bottom and left) that we can use so that how much that element moves from a specific position.</p><p>Ok. Let&#39;s look at what these properties are and how it works:</p><h4>position: static;</h4><p>This is the default value for the position property and this does not accept any box-offset property. It means each and every element in a page is a static element by default which cannot be moved using left, right, top, or bottom property. The default static value can be overwritten using relative, absolute, and fixed.</p><p>The code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LVKuElYRGtSSHqXVKZbw3w.png" /></figure><p>And In our browser:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M1iUZJeSffVyqL5OrzX9ag.png" /></figure><p>Here, our box doesn’t move despite giving top and left offset properties because its position is static.</p><h4>position: relative;</h4><p>The relative positions move an element to any offset from its previous position. It accepts all the box-offset properties. We can move the relatively positioned element using box-offset properties. The relatively positioned element is that it will always remain in the normal flow of the page, unlike floated elements. If we position any relatively it’s original position will be maintained, no elements can take its original position. It keeps occupying its original place and moves to the specified offset from its relative position:</p><p>Let&#39;s have a look:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1dZPkPiR4fbvHIZP6poQgQ.png" /></figure><p>Our blue-box has moved 50px from top and bottom maintaining its original space:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hcYfAHLQ-yOGF08KJNfrXw.png" /></figure><h4><strong>position: absolute;</strong></h4><p>Absolutely positioned elements accept all the box-offset properties. Similar to relative elements we can move the absolute elements in its coordinates. But here’s a catch: Whenever we position any elements absolutely it goes out of the flow and it is removed from the normal flow of the page. That means its original position will be lost and the next upcoming element will take its position.</p><p>Positioning absolute also changes the display property. When we set the position property to a relative, the elements start behaving weirdly. For eg, the block-level elements start taking up space according to the width of their content and inline-level elements might start accepting width and height. Which is weird, right, I understand. But not as weird as floats.</p><p>Let&#39;s look at the example for a good grasp:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5-UQSNKHsTkc-23iiwhuXw.png" /></figure><p>Our red-box moves upward and takes the original space of blue-box because the blue-box is out of the now:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pDiDGOs9y_f7sCQxDQWo0Q.png" /></figure><p><strong>One more thing</strong>: If we don’t provide any box-offset properties to absolute elements, the element will remain absolutely positioned in its original position but on Z-axis, its X and Y plane will be lost. Therefore the next element will take the original position of the absolute element and the absolute element will be on top of it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pp7GV721P6NmtCD-k0_w-g.png" /><figcaption>Our red-box is behind the blue-box</figcaption></figure><h4>Ways to use <strong>position: absolute;</strong></h4><p>There are two ways we can use absolute positioning:</p><ul><li>Setting<strong> position: relative </strong>to the parent element of the child having <strong>position: absolute, </strong>so that the child has a threshold (of its parent) to look upon :</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ShATm3v2IQ5Y94uHcPn2aQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3fXRfy7rcIodAbnXPba_gw.png" /></figure><ul><li>If we don’t make its parent <strong>position relative</strong> then the <strong>box-offset property </strong>of the <strong>absolute element</strong> will work<strong> relative to the body</strong> of the page:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y02Du9ekaQIfGIVDVIf9mA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xz4rDzoWGnvbCIzr3GFLdQ.png" /></figure><h4>position: fixed;</h4><p>The element with <strong>position: fixed</strong> is removed from the flow of the document like absolutely positioned elements. In fact they behave almost the same, only fixed positioned elements are always relative to the document, not any particular parent, and are unaffected by scrolling.</p><p>Here’s an example. Just look at the<strong> btn-top</strong> for now and its <strong>position</strong> which is <strong>fixed</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fwBHRohwo-L583NnvWQP4w.png" /></figure><p>If you put lots of contents and have the scroll bar, you’ll see that it is just fixed in its position irrespective of how much we scroll:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T0VqUPykYhyWb07RjaBeMg.png" /></figure><h3>The z-index property</h3><p>The <strong>z-index</strong> property in CSS controls the vertical stacking order of elements that overlap. As in, which one appears as if it is physically closer to you. <strong>z-index</strong> only effects elements that have a position value other than static (the default).</p><p>For eg,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/0*lrX1UxTXBh-1Zryd.png" /></figure><p>That’d be it for today.</p><p>Hey! I’m glad you make up till here. I hope you got to know something useful.</p><p>It&#39;s Ok if these things take time to understand. But remember,</p><p><strong>Time is your friend; impulse is your enemy</strong></p><p>Anyway, in case we are meeting for the first time, hello. My name is Anas Ansari. I write about <a href="https://medium.com/@anasansari157">stuff that I understand</a>. I’m learning Full Stack Development at <a href="http://altcamous.io/">AltCampus</a>.</p><p>Thanks for your time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2110f5af9c2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Positioning things in CSS using floats]]></title>
            <link>https://medium.com/@anasansari157/positioning-things-in-css-using-floats-9721d833d283?source=rss-cd34785a845f------2</link>
            <guid isPermaLink="false">https://medium.com/p/9721d833d283</guid>
            <category><![CDATA[html-css]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[box-model]]></category>
            <dc:creator><![CDATA[Anas Ansari]]></dc:creator>
            <pubDate>Tue, 26 Nov 2019 20:17:11 GMT</pubDate>
            <atom:updated>2019-11-26T20:17:11.529Z</atom:updated>
            <content:encoded><![CDATA[<h4>Why it is the most difficult thing in CSS and how to overcome it</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*CFwJ6lMQMOi4Oy7L8Mn17g.png" /><figcaption><a href="http://anything.codes/gdi-intermediate-html-css/class4.html#/">http://anything.codes/gdi-intermediate-html-css/class4.html#/</a></figcaption></figure><p>OK. So previously, we came across something called Box Model in CSS. We learned how every element behaves as a rectangular box and how much space it takes up. We also learned about the ways to tackle and change the way an element behaves on a page by using display properties and their advantages over one another. We brushed up on a few important properties like margin, padding, border, etc.</p><p>Now, We are to learn how we position things in CSS using floats. What are its limitations, how to overcome them and ways to overcome them? Let’s dive in.</p><h3>What’s wrong with the Box Model?</h3><p>By default, every element on a webpage behaves like a box, i.e. whether you specify width or not it takes a shape of box enclosing content inside it. If the width isn’t specified it takes up the whole available width of the parent element.</p><p>Wait, there’s more. In a webpage full of content, elements are stacked over one another. That makes a website really boring and often lengthy. Like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*IbeEfKguwHynBFJDAdRahg.png" /></figure><p>Whereas in our daily lives we experience content dynamically and not just in one flow. One good example is newspapers. In newspapers, we see headings paragraphs and images that are wrapped inside those paras. Like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/0*PTCDFUfhbPDFkZKH.png" /><figcaption><a href="https://css-tricks.com/wp-content/csstricks-uploads/print-layout.png">https://css-tricks.com/wp-content/csstricks-uploads/print-layout.png</a></figcaption></figure><p>Here comes the float</p><h3>What is the float?</h3><p>The <strong>float</strong> CSS property places an element on the left or right side of its container, allowing text and inline elements to wrap around it. The element is removed from the normal flow of the page, though still remaining a part of the flow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/0*HQfak27L19oG9njJ.png" /><figcaption><a href="https://css-tricks.com/wp-content/csstricks-uploads/web-text-wrap.png">https://css-tricks.com/wp-content/csstricks-uploads/web-text-wrap.png</a></figcaption></figure><p>There are four valid values for the float property:</p><ul><li><strong>Left</strong> is used for floating elements in the left direction.</li><li><strong>Right</strong> is used for floating elements in the right direction.</li><li><strong>None</strong> (the default) ensures the element will not float</li><li><strong>Inherit</strong> which will assume the float value from that elements parent element.</li></ul><h3>Use Of floats</h3><p>The float was created for wrapping images around the content when the web wasn’t developed that much. But now it can also be used to design the layout of the webpage (which is not preferred by many but you can do it).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/0*jwBtXSiCTKqaUV4i.png" /><figcaption><a href="https://css-tricks.com/wp-content/csstricks-uploads/web-layout.png">https://css-tricks.com/wp-content/csstricks-uploads/web-layout.png</a></figcaption></figure><blockquote>While floats can still be used for layout, these days, we have much stronger tools for creating layout on web pages</blockquote><p>Let us see the <strong>float </strong>in<strong> </strong>use:</p><p>Let’s create an image element and a paragraph supporting the image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OQPce2ZkcnKfqrOzZaRaeA.png" /></figure><p>And the magic happens in the browser:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lGhs7jJCY9CqIy4hxDFyhg.png" /></figure><p>So beautiful! I could look at it all day. Just to keep things in perspective, here’s what it would look like without float:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KwQKDCsR-QqC_tfd34OIxQ.png" /></figure><p>Aren’t you loving <strong>float </strong>already?</p><p>Ummm… wait. There is one more thing. Now things are gonna get messy.</p><p>When you use float for something other than floating elements around the content, it might behave a little bit odd. Sometimes you may want to force an item to move below any floated elements. For instance, you may want paragraphs to remain adjacent to floats, but force headings to be on their line. For that, we use clear property.</p><p>The <strong>clear</strong> property sets whether an element must be moved below (cleared) floating elements that precede it. The clear property applies to floating and non-floating elements.</p><p>Let’s understand it with the help of an example. Let’s take two images and give them float property of left and right respectively. And make a box below that. Here is what our code should look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LQfW0z1Dc5a2dFtY4TEoGQ.png" /></figure><p>And in the browser:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i4qt6CJbRPFgjkHpy4dvhw.png" /></figure><p>Where is our red box? We can see our beautiful pigs but not the red box. That’s because we didn’t clear the element below our floated elements. Let’s apply <strong>clear: both</strong> to our red box. In the browser, we now see our red box.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GgVZaK1bQoKAP6k6Q6SqMQ.png" /></figure><p>Huee….. Our red box is back now. See, that’s why we use clear: both to the upcoming element after the floated elements.</p><p>There are various techniques that we can use to fix the disappearance of elements:</p><ul><li><a href="https://css-tricks.com/all-about-floats/"><strong>The Empty Div Method</strong></a></li><li><a href="https://css-tricks.com/all-about-floats/"><strong>The Overflow Method</strong></a></li><li><a href="https://css-tricks.com/all-about-floats/"><strong>The Easy Clearing Method</strong></a></li></ul><p>We will talk about them later. It might be new to grab concepts like that. That’s it for now. And remember,</p><p><strong>Perseverance beats talent.</strong></p><p>Anyway, in case we are meeting for the first time, hello. My name is Anas Ansari. I write about <a href="https://medium.com/@anasansari157">stuff</a> that I understand. I’m learning Full Stack Development at <a href="http://altcamous.io/">AltCampus</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9721d833d283" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Box Model and a few CSS properties]]></title>
            <link>https://medium.com/@anasansari157/box-model-and-a-few-css-properties-eade1487d522?source=rss-cd34785a845f------2</link>
            <guid isPermaLink="false">https://medium.com/p/eade1487d522</guid>
            <category><![CDATA[padding]]></category>
            <category><![CDATA[margin]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[box-model]]></category>
            <dc:creator><![CDATA[Anas Ansari]]></dc:creator>
            <pubDate>Tue, 26 Nov 2019 04:29:08 GMT</pubDate>
            <atom:updated>2019-11-26T04:29:08.947Z</atom:updated>
            <content:encoded><![CDATA[<h4>How the elements on a webpage behave</h4><p>If you’re following up with me on my journey to becoming a Full Stack Web Developer, we covered the basics of HTML and CSS so far. If you haven’t gone through the<a href="https://medium.com/@anasansari157"> previous articles</a>, please go through it to understand better.</p><p>Now its time to look upon the things that are governed in CSS by default.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*mD8dgX0ccqrKd6u3o1w0Kg.png" /></figure><h3>What is Box Model?</h3><p>Every content we put in for our webpage is wrapped inside the element. The elements are just <strong>boxes</strong> that wrap our content inside them. For instance,</p><p>Let’s create an <strong>index.html</strong> file and define a <strong>paragraph</strong> <strong>tag</strong> with some content in it and give it the <strong>background-color</strong> property of <strong>value</strong>, <strong>red. </strong>Now if you open the HTML file in the browser, it would look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vrdwid3GC72Dj5asv7jSXA.png" /></figure><p>You see it, right? Why that paragraph is taking up the whole rectangular space despite our content is just a few words long? The reason is every element on the webpage is treated as a rectangular box by default (with few exceptions like &lt;a&gt; tag, &lt;img&gt; tag, and a handful more).</p><p>Let’s try that again to get our concept more clear:</p><p>Here’s our HTML file with CSS styles in the head tag (which is not an ideal way, we should always link it externally to keep our code clean):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M0RZIyKyMhfsISUfpYaDPQ.png" /></figure><p>Here is what it looks like in the browser:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6KxZBqlfEImLE5YIo1HW0g.png" /></figure><p>See, every element is taking up the whole width of the page and has the height wrt to the content of the element.</p><p><strong>Experiment Yourself</strong>: Go on and add some more texts in those paragraphs. What did you see? Did the height of the paragraph element change? It’s is still rectangular, right? That’s our <strong>Box Model.</strong></p><h3>Display properties</h3><p>Sometimes we don’t want a particular tag to take up the whole available space, maybe because you wanna add another element just beside it or you want the space to be left blank to maintain clarity, whatever it may be.</p><p>To tackle that problem CSS comes with a bunch of display value that changes how much space we want that element to acquire.</p><p>Some values of the display property are:</p><h4>display: block;</h4><p>By default, the browser treats every element on the page as block/ box of a kind in which our content resides. The examples of this property we had seen afore.</p><h4>display: inline;</h4><p>To make any element to take up the only space equal to the width of the content, we use the <strong>inline </strong>property.</p><p>For instance, let us bring back our previous example and give the paragraph element the property of <strong>display: inline;</strong></p><p>Can you guess what would happen here?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C_2Q4wJH483hXm1cTqWnhQ.png" /></figure><p>You’re right. The elements that were taking up the whole of the available width, now take only space they require as per their content. Here is what it would like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JHgjX05bndHvWQhNb76wkg.png" /></figure><h4>display: inline-block;</h4><p>Isn’t it cool that we can give elements the only space they need to align them horizontally by using just <strong>display: inline</strong> property? I’m sure that is. But, what if we want our inline elements to take a specific height and width defined by us? If we give the width property to the inline elements, it won’t work because inline elements don’t take height and width manually. For that element to take a specified width and height and few other properties (we will talk about them later), we use <strong>display: inline-block </strong>property.</p><p>Let’s get back to our code and change display property to inline-block and give the element some specific dimensions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S7uQP9VxBeCT_Rfx1craYQ.png" /></figure><p>It would look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g_brY73T0ytrLHyDdIs5Sw.png" /></figure><p>And… Voila! It works! All of our paragraphs have width of 200px;</p><p>It’s fun, isn’t it?</p><p>We now know What Box Model is and how to change the properties of it to assess with our needs. Let’s learn a bit more about the box model and specifically, the properties that come with it.</p><h3>Padding</h3><p>Padding is the space between the content and the border of the element. If we want an element to have a space between its content and its border, we use <strong>padding.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/206/1*zWfrkoVM-ZnN5Ppeg5B3ZQ.png" /></figure><h3>Border</h3><p>The border is the outline we provide to the content to enhance its view or make things clear(or whatever your reasons maybe).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/291/1*PL2lw6UqAy6DWIux8X3ljQ.png" /></figure><h3>Margin</h3><p>Margin is the space between two elements or their borders. We apply margin when we want two elements to be apart from each other (and you will want this often, trust me).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/263/1*X21d4X8A0RJz9MxCcWefBg.png" /></figure><p>So, now let’s add all of them up and see them in use:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bLwRKClCh9lFX7ceshZqaQ.png" /></figure><p>Here is the result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pLaS7gTT2q_oH1jw4H7FIg.png" /></figure><p>WOW! Exceptional, isn’t it? You can inspect in the browser to see how things are working.</p><p>Ok, that’s it for now. It might get overwhelming if we learn too many things at once so I’ll wait till you grab the aforementioned concepts because as you know…</p><p><strong>If you are to cut a tree in six hours, it would be better if you sharpen our axe for the first four.</strong></p><p>Anyway, in case we are meeting for the first time, hello. My name is Anas Ansari. I write about <a href="https://medium.com/@anasansari157">stuff</a> that I learn. I’m learning Full Stack Development at <a href="http://altcamous.io/">AltCampus</a>.</p><p>Thank you for your time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eade1487d522" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting to know CSS better]]></title>
            <link>https://medium.com/@anasansari157/getting-to-know-css-better-33032efd64dd?source=rss-cd34785a845f------2</link>
            <guid isPermaLink="false">https://medium.com/p/33032efd64dd</guid>
            <dc:creator><![CDATA[Anas Ansari]]></dc:creator>
            <pubDate>Thu, 21 Nov 2019 20:01:58 GMT</pubDate>
            <atom:updated>2019-11-21T20:01:58.041Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learning CSS in detail.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*yD0R1ZSHZIrUrlEiUqarWA.png" /></figure><p>This is the second part of the series I’m writing about HTML and CSS. If you haven’t read the first one, read it <a href="https://medium.com/@anasansari157/what-the-heck-is-html-css-28147821ee8a">here</a>.</p><p><strong>Things to take away from the previous diurnal:</strong></p><ul><li>We know what technologies are used to build a simple and basic website, i.e HTML, CSS and JavaScript. And also what are their roles.</li><li>We learned about tags, elements and different types of tags in HTML. We now know how to structure our HTML webpage.</li><li>We learned how we put styles to our boring HTML and how to make it more desirable to the eye.</li><li>We learned about the ways of linking our CSS styles to our HTML page: inline, internal and external.</li><li>We also created our first website on which we laid out some CSS styles.</li></ul><h3><strong>Brushing up on CSS</strong></h3><p>Let&#39;s break up the CSS style we applied earlier to understand it better.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/1*1A8Wm0cNJJVTXSXStCDyhA.png" /></figure><p>Here, <strong>p</strong> is called <strong>selector</strong> as it hooks on the tag that we want to add styles on. <strong>background-color </strong>is called the <strong>property </strong>that we apply on the selector and <strong>green </strong>is the <strong>value </strong>we give to our property. Together with all this, we call it a <strong>rule-set</strong>.</p><h3>Types of Selectors</h3><p>There are many ways we select an element in our HTML file.</p><p><strong>Type Selector: </strong>The above way we have seen just now is the type selector. In this, we target an element with the element name or type.</p><p><strong>Class Selector: </strong>Class Selector allows us to target an element with the class attribute inside the tag. The class selector is denoted by . followed by the given class name. For eg,</p><pre>Our HTML:<br>&lt;div class=&quot;header&quot;&gt;.........&lt;/div&gt;</pre><pre>Our CSS:<br>  .headre {<br>    text-align: center;<br>  }</pre><p><strong>ID Selector: </strong>We define ID attribute also inside a tag. But to target an element using an ID selector in CSS we use <strong># </strong>followed by the value defined inside the ID attribute. The ID is used only one specific ID(with one name) per HTML page. For eg,</p><pre>Our HTML:<br>&lt;div id=&quot;footer&quot;&gt;&lt;/div&gt;</pre><pre>Our CSS:<br>  #footer {<br>    background-color: green;<br>  }</pre><p>We can use any number of classes or specific ID on a particular tag.</p><h4>Hyperlinks</h4><p>We create a link using an anchor tag &lt;a&gt;, and inside the tag, we define href attribute, also known as <strong>hyperlink reference. </strong>Like:</p><pre>&lt;a href=&quot;https://anasansari.github.io/&quot;&gt;Anas Ansari&lt;/a&gt;</pre><p>It is most common to see that few links in a page connect to the other page of the same website as well as few links connect to a different website. For instance,</p><pre>&lt;a href=&quot;about.html&quot;&gt;About&lt;/a&gt;                       --Relative Path<br>&lt;a href=&quot;https://www.google.com/&quot;&gt;Google&lt;/a&gt;         --Absolute Path</pre><p><strong>Relative Path: </strong>If the link connects to the other pages of the same website then it is considered as a <strong>relative path</strong>.</p><p><strong>Absolute Path: </strong>If the link connects to another website which is entirely different from the current one, then it is known to have an <strong>absolute path</strong>.</p><h3>CSS Reset</h3><p>Every browser has default styles for different elements. For example, the way a Chrome browser will display heading elements, in a similar way safari won’t. To ensure cross-browser similarities CSS resets are widely used. CSS resets takes all the element and provides unified styles for all browser. It removes all the default sizing, margin, padding and all the additional styles from the element. There are many CSS resets. One we commonly use is <strong>Eric Meyer’s Reset:</strong></p><pre>/* http://meyerweb.com/eric/tools/css/reset/<br>   v2.0 | 20110126<br>   License: none (public domain)<br>*/<br><br>html, body, div, span, applet, object, iframe,<br>h1, h2, h3, h4, h5, h6, p, blockquote, pre,<br>a, abbr, acronym, address, big, cite, code,<br>del, dfn, em, img, ins, kbd, q, s, samp,<br>small, strike, strong, sub, sup, tt, var,<br>b, u, i, center,<br>dl, dt, dd, ol, ul, li,<br>fieldset, form, label, legend,<br>table, caption, tbody, tfoot, thead, tr, th, td,<br>article, aside, canvas, details, embed,<br>figure, figcaption, footer, header, hgroup,<br>menu, nav, output, ruby, section, summary,<br>time, mark, audio, video {<br>    margin: 0;<br>    padding: 0;<br>    border: 0;<br>    font-size: 100%;<br>    font: inherit;<br>    vertical-align: baseline;<br>}<br>/* HTML5 display-role reset for older browsers */<br>article, aside, details, figcaption, figure,<br>footer, header, hgroup, menu, nav, section {<br>    display: block;<br>}<br>body {<br>    line-height: 1;<br>}<br>ol, ul {<br>    list-style: none;<br>}<br>blockquote, q {<br>    quotes: none;<br>}<br>blockquote:before, blockquote:after,<br>q:before, q:after {<br>    content: &#39;&#39;;<br>    content: none;<br>}<br>table {<br>    border-collapse: collapse;<br>    border-spacing: 0;<br>}</pre><h3>Cascading</h3><p>Cascading means <strong>waterfall. </strong>When CSS gets loaded in the browser, it reads from top to bottom i.e, if we define the same property with different values on a particular selector, the last CSS rule set will get applied to that element. Just like a waterfall, the flow of the CSS is from top to bottom. For eg,</p><pre>h1 {<br>  background: violet;<br>  font-size: 30px;<br>}<br>h1 {<br>  background: green;<br>}</pre><p>The background of h1 will be green because the browser reads styles from top to bottom cascading.</p><h3>Specificity</h3><p>Specificity is nothing but the priority given to the selectors over each other. In the specificity table, type selector has the lowest weight, class selectors have medium weight and ID selector has the highest weight. Let’s have a look at the table and the point of how much each selector hold.</p><p><strong>Type Selector </strong>has a specificity of <strong>0–0–1</strong>;</p><p><strong>Class Selector </strong>has a specificity of <strong>0–1–0</strong>; while</p><p><strong>ID Selector </strong>has a specificity of <strong>1–0–0</strong>.</p><p>Let&#39;s understand it better with the help of an example:</p><pre>Our HTML:<br>&lt;p class=&quot;door&quot; id=&quot;anotherDoor&quot;&gt;...&lt;/p&gt;</pre><pre>Our CSS:<br>  #anotherDoor {<br>    background: red;<br>  }<br>  .door {<br>    background: green;<br>  }<br>  p {<br>    background: orange;<br>  }</pre><p>Here if we run the code in the browser, we will notice that the background color of the paragraph is changed to <strong>red. </strong>It is because the ID has highest specificity of all the three selectors.</p><p>And that&#39;s enough for the day. It might be long but it&#39;s worth knowing all this stuff. It would be better we keep things slow because…</p><p><strong>Slow And Steady Wins The Race.</strong></p><p>In case we are meeting for the first time, hello. My name is <strong>Anas Ansari</strong>. I am learning Full Stack Development at <a href="http://altcampus.io/">AltCampus</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33032efd64dd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What the heck is HTML & CSS?]]></title>
            <link>https://medium.com/@anasansari157/what-the-heck-is-html-css-28147821ee8a?source=rss-cd34785a845f------2</link>
            <guid isPermaLink="false">https://medium.com/p/28147821ee8a</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[html]]></category>
            <dc:creator><![CDATA[Anas Ansari]]></dc:creator>
            <pubDate>Wed, 20 Nov 2019 04:38:23 GMT</pubDate>
            <atom:updated>2019-11-20T04:38:23.372Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learning Web Development the right way.</h4><p>I was introduced to Web Development around a year ago, and since then I have been aspiring to come into this field. After reading many many and many articles about how to learn, where to start, how much time it would take me to learn a particular technology, I came across AltCampus — a coding boot camp in a Himalayan village called Dharmshala. And since life is good now. It has been just a few days since I came here but I have already learned so many things and did projects that might have taken me a month, at least.</p><p>I am writing this article so that I can emphasize on the things I have learned yet and retain it for a longer time, to see if I can explain things that I learned till now. If you find anything useful, please follow along with me.</p><h3>Building blocks of a Website</h3><p>A website is generally built of three main components- HTML, CSS, and JavaScript.</p><ul><li>The HTML stands for Hyper-text Markup Language. It defines the structure of your website. Defining how things are to be laid out on a particular webpage is what HTML is used for. It can be compared to the body of a human.</li><li>CSS is used to put styles to our coded plain HTML to make things look more desirable to the user. It also helps in maintaining the continuity of a website. Hence, the name Cascading StyleSheet. Concerning our human body example, we can say that CSS is how we put clothes and make-up on that body.</li><li>The JavaScript is a medium to provide interaction with the website. Its the only programming language for the logic. Javascript helps to tell that human what to do.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*KRq7jQOUdQsHNsZa72XcDw.jpeg" /><figcaption><a href="https://www.pinterest.ca/pin/571183165342554995/?autologin=true">https://www.pinterest.ca/pin/571183165342554995/?autologin=true</a></figcaption></figure><h3>HTML</h3><p>To create an HTML file, open a text editor and save the document with <em>.hmtl </em>extension. For eg, <em>index.html. </em>HTML is just a markup language. It means we enclose a particular text; para or heading, inside a pair of tags.</p><p>An HTML file consists of a pair of HTML tag (&lt;html&gt;&lt;/html&gt;), inside which there’s a head tag (&lt;head&gt;&lt;/head&gt;) and body tags (&lt;body&gt;&lt;/body&gt;). Inside the head tag, we put extra information about the page, like links to the CSS file(we will understand this later). And our content that we want to display goes inside the body tag. Now our HTML file would look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*yvIBVhQiN-M33r9LbMnH3g.png" /></figure><p>To write the contents of a webpage, we write the way we write in English but with our pair of tags. The general syntax for our content would be like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*PHrGbCGm-Zk7_1bDBI_9CA.png" /><figcaption>Opening tag + Content + Closing tag</figcaption></figure><p>For paragraph we use &lt;p&gt; tag. So our paragraph becomes:</p><p>&lt;p&gt;Hello World&lt;/p&gt;</p><p>The content with its opening and closing tag is called an <strong>Element</strong>.</p><p>Similarly, we have tags for</p><ul><li><strong>Headings</strong>- &lt;h1&gt;,&lt;2&gt;,&lt;h3&gt;,&lt;h4&gt;,&lt;h5&gt;,&lt;h6&gt;.</li><li><strong>Images- </strong>&lt;img&gt; (Its a self closing tag: it doesn’t require a closing tag).</li><li><strong>Links- </strong>&lt;a&gt;&lt;/a&gt;.</li></ul><p>There are many more but we use these often.</p><p>Let’s give heading, a paragraph and an image followed by a link to our page and After putting the contents our <em>index.html </em>file looks something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*imxDZJjk-rUMy6uftWy2ow.png" /></figure><h3>CSS</h3><p>Till now, we have defined the structure of our page. If we open our HTML file in the browser, we see:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WbQyE-YRmEW2OtV-92mhUQ.png" /></figure><p>Boring as hell, isn’t it?</p><p>That’s where CSS comes into play. We use CSS to put styles to our page, like changing font size, background color or an image in the background, aligning things, etc.</p><p>To use CSS we have three ways to tell the browser to connect with the HTML file:</p><ol><li>Inline- Inside the opening tag and specifying the styles in that line preceded by the keyword <strong>style</strong>. For eg,</li></ol><p>&lt;p style=“color: green”&gt;Hello World&lt;/p&gt;.</p><p>This changes the color of the paragraph text to green.</p><ol><li>Internal- Defining our styles inside head tag, enclosed in &lt;style&gt;&lt;/style&gt;</li><li>External- Creating a file with extension .<em>css</em> (as in styles.css) and then declaring the styles in the file. We then link the file using <strong>&lt;link&gt; </strong>tag inside the head of our<strong> index.html</strong> file. This is the preferred way to style our file, to make our code more clean and lenient. We will be doing the same for our website.</li></ol><p>Let’s create a file with name main.css and link it to our Html file.</p><p>To put styles on content, we select the tag of our content (on which we want to put styles on) and define what we want to do. To target the tag, we use selectors. Selectors are basically hooks that help to apply our styles on the selected tag.</p><p>For instance, if we want to change the background color of the paragraphs on our webpage, our CSS code should look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/1*_Voa3gKjQ_RSSwsxM2lE8w.png" /></figure><p>Let’s break up the code to understand what these things do.</p><p>p- Here p is a <strong>selector</strong>, working as a hook on which we can add styles on.</p><p>background-color- It is a <strong>property</strong> used to change the background color of an element.</p><p>green: It is a <strong>value</strong> given to the property to apply to the selected element.</p><p>Every style should be in this format only i.e. Selector enclosing property-value pair inside parentheses.</p><p>After applying some styles (or CSS) our code should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/1*NZ-TXpb5VJ9dYC7pGK_vog.png" /></figure><p>After linking the main.css, our index.html file looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hhJa-0qITUWvD6Upp-rmjA.png" /></figure><p>Here’s our webpage now:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JECO9d6VOCbzLMRXbimeDg.png" /></figure><p>Much better than before. It is more desirable than before. It makes our webpage more intuitive.</p><p>That’s it for now. It might be overwhelming if you’re learning all this for the first time.</p><p><strong>Let’s Be Short And Be Consistent.</strong></p><p>Anyway, if you want to learn more here’s the <a href="https://medium.com/@anasansari157">link to my next article</a> in case you are in a hurry.</p><p>In case we are meeting for the first time, hello. My name is <strong>Anas Ansari</strong>. I am learning Full Stack Development at <a href="http://altcampus.io/">AltCampus</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28147821ee8a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>