<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Cathy</title>
    <description>The latest articles on Forem by Cathy (@geeklady).</description>
    <link>https://forem.com/geeklady</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F390369%2Fb8baeefa-81c1-42ee-a0c3-c44368aec0b3.jpeg</url>
      <title>Forem: Cathy</title>
      <link>https://forem.com/geeklady</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/geeklady"/>
    <language>en</language>
    <item>
      <title>How to position an element under a fixed element</title>
      <dc:creator>Cathy</dc:creator>
      <pubDate>Thu, 16 Jul 2020 11:06:27 +0000</pubDate>
      <link>https://forem.com/geeklady/how-to-position-an-element-under-a-fixed-element-182n</link>
      <guid>https://forem.com/geeklady/how-to-position-an-element-under-a-fixed-element-182n</guid>
      <description>&lt;p&gt;Here's my first article on Dev.to! 🚀 🚀 🚀&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem description
&lt;/h2&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/bipubipu-the-decoder/embed/rNxqWZZ?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;The beneath element was blocked by the above element.&lt;/p&gt;

&lt;p&gt;You may have met this problem when you have a fixed nav bar. &lt;/p&gt;

&lt;h2&gt;
  
  
  Analysis
&lt;/h2&gt;

&lt;p&gt;What should you do then?&lt;/p&gt;

&lt;p&gt;Change the margin-top of #content element. But to what value?&lt;/p&gt;

&lt;p&gt;We can set a fixed value but it might not look good.&lt;/p&gt;

&lt;p&gt;This is going to be a responsive webpage, so the height of #fix div is changing as you change the size of the window.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;Use jQuery to change CSS with a dynamic value.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/bipubipu-the-decoder/embed/NWxOdme?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;You may need to add jQuery to your html code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" rel="noopener noreferrer"&gt;https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I used CodePen to do this demo, which only needs to change the setting. &lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgeekladysite.files.wordpress.com%2F2020%2F07%2Fscreen-shot-2020-07-16-at-8.19.05-pm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgeekladysite.files.wordpress.com%2F2020%2F07%2Fscreen-shot-2020-07-16-at-8.19.05-pm.png" width="800" height="522"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After adding this code snippet, it works fine. But wait a sec. If you click HTML/CSS/JS button in codepen or drag your browser window, the result is not right again.  &lt;/p&gt;

&lt;p&gt;Why? Because the window size has changed. So we need to let the size change to be a trigger. &lt;/p&gt;

&lt;p&gt;In the end, we need to add the following code to solve the problem. One changes the CSS when the page is loaded. The other changes when window resizes. Problem solved!&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/bipubipu-the-decoder/embed/bGEmgPO?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function dynamicHeight(){
     $('#content').css("margin-top", $('#fix').height());
}
$(document).ready(dynamicHeight);
$(window).resize(dynamicHeight);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;About jQuery functions, it's a little different from JS. I firstly used 'dynamicHeight()', and failed. &lt;/p&gt;

&lt;p&gt;If you have other solutions, feel free to contact me! I’m eager to learn! This is firstly published at my blog: &lt;a href="https://geekladysite.wordpress.com" rel="noopener noreferrer"&gt;https://geekladysite.wordpress.com&lt;/a&gt;. Check that too if you're interested!&lt;/p&gt;

</description>
      <category>css</category>
      <category>beginners</category>
      <category>jquery</category>
    </item>
    <item>
      <title>Questions about float-point numbers</title>
      <dc:creator>Cathy</dc:creator>
      <pubDate>Thu, 18 Jun 2020 10:09:41 +0000</pubDate>
      <link>https://forem.com/geeklady/questions-about-float-point-numbers-2n74</link>
      <guid>https://forem.com/geeklady/questions-about-float-point-numbers-2n74</guid>
      <description>&lt;p&gt;I roughly know how float point system works. But I don't know why the second looks normal?&lt;/p&gt;

&lt;p&gt;If I run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(1.01+2.05);
console.log(1.01+2.05+4.21);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I'll get&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;3.0599999999999996
7.27
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also, I see some people multiply the number by 100 and add them up, finally divide it by 100. Doesn't this solution have any problem? What if the number is really big? There's overflow concern, isn't it? &lt;/p&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
