<?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: Azam</title>
    <description>The latest articles on Forem by Azam (@azam4code).</description>
    <link>https://forem.com/azam4code</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%2F35034%2Fe5b9386c-1daa-4fa6-ac5e-3b493927ccd3.png</url>
      <title>Forem: Azam</title>
      <link>https://forem.com/azam4code</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/azam4code"/>
    <language>en</language>
    <item>
      <title>Understanding CSS Logical Properties</title>
      <dc:creator>Azam</dc:creator>
      <pubDate>Mon, 26 Jun 2023 03:34:52 +0000</pubDate>
      <link>https://forem.com/azam4code/understanding-css-logical-properties-192n</link>
      <guid>https://forem.com/azam4code/understanding-css-logical-properties-192n</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;em&gt;CSS logical&lt;/em&gt;&lt;/strong&gt; properties are a powerful tool for building flexible, responsive web layouts. By using logical properties instead of traditional physical properties in your CSS code, you can create designs that adapt automatically to different screen sizes and orientations, without having to write multiple versions of the same layout rules. Logical properties allow you to express your layout logic in terms of start/end instead of left/right or top/bottom, which makes it easier to create layouts that work in any language or writing direction. With logical properties, you can simplify your code, reduce redundancy, and build more efficient, dynamic websites that are ready for the modern web.&lt;/p&gt;

&lt;p&gt;CSS Logical Properties provide a way to define layout rules based on the logical (start/end) values rather than the physical (left/right) values. This makes it much easier to create layouts that work across different writing modes such as LTR (left-to-right) and RTL (right-to-left).&lt;/p&gt;

&lt;p&gt;Here's an example of using logical properties for a simple layout:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="container"&amp;gt;
  &amp;lt;div class="box"&amp;gt;&amp;lt;/div&amp;gt;
  &amp;lt;div class="box"&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container {
  display: flex;
  flex-direction: column;
}

.box {
  height: 50px;
  width: 50px;
  background-color: red;
  margin: 10px;

  /* Logical Properties */
  margin-inline-start: 20px;
  margin-inline-end: 20px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we have a box layout with two boxes stacked on top of each other in a container. We've set the container to be a flexbox with a vertical direction, which means that the boxes will stack on top of each other instead of side-by-side.&lt;/p&gt;

&lt;p&gt;To space the boxes out evenly, we could use margin-left and margin-right properties in the box styles. However, this can cause problems if the text direction changes, such as with languages that are read right-to-left instead of left-to-right.&lt;/p&gt;

&lt;p&gt;Instead, we've used CSS logical properties called margin-inline-start and margin-inline-end. These properties behave like margin-left and margin-right, but adjust themselves based on the writing mode. This means that if the text direction is left-to-right, margin-inline-start will act like margin-left. If the text direction is right-to-left, margin-inline-start will act like margin-right.&lt;/p&gt;

&lt;p&gt;This makes it much easier to create layouts that work well across different languages and writing modes without having to adjust the styles manually.&lt;/p&gt;

&lt;h4&gt;
  
  
  Another Example
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="box"&amp;gt;
  &amp;lt;p&amp;gt;Hello World!&amp;lt;/p&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.box {
  width: 50%;
  height: 200px;
  padding-inline: 10%;
  margin-inline: auto;
  border-block-end: 2px solid black;
}

p {
  padding-block: 1em;
  margin-inline: 0;
} 

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we have a div element with the class of .box that contains a p element. We're using all the available CSS logical properties to style them.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;width&lt;/em&gt;&lt;/strong&gt;: Sets the width of the box to 50% of its containing block.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;height&lt;/em&gt;&lt;/strong&gt;: Sets the height of the box to 200 pixels.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;padding-inline&lt;/em&gt;&lt;/strong&gt;: Sets the horizontal padding of the box to 10% of its containing block. This property replaces &lt;strong&gt;&lt;em&gt;padding-left&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;padding-right&lt;/em&gt;&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;margin-inline&lt;/em&gt;&lt;/strong&gt;: Centers the box horizontally by setting the left and right margins to auto. This property replaces &lt;strong&gt;&lt;em&gt;margin-left&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;margin-right&lt;/em&gt;&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;border-block-end&lt;/em&gt;&lt;/strong&gt;: Adds a 2-pixel thick black border to the bottom of the box. This property replaces &lt;strong&gt;&lt;em&gt;border-bottom&lt;/em&gt;&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;padding-block&lt;/em&gt;&lt;/strong&gt;: Adds vertical padding of 1em to the p element. This property replaces &lt;strong&gt;&lt;em&gt;padding-top&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;padding-bottom&lt;/em&gt;&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;margin-inline&lt;/em&gt;&lt;/strong&gt;: Removes the default left and right margins from the p element. This property replaces &lt;strong&gt;&lt;em&gt;margin-left&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;margin-right&lt;/em&gt;&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By using logical properties, we can write more maintainable and flexible code that adapts better to different screen sizes and orientations.&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>css3</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Building Better Websites with CSS and JavaScript Motion Design</title>
      <dc:creator>Azam</dc:creator>
      <pubDate>Sun, 23 Apr 2023 19:18:36 +0000</pubDate>
      <link>https://forem.com/azam4code/building-better-websites-with-css-and-javascript-motion-design-1bb9</link>
      <guid>https://forem.com/azam4code/building-better-websites-with-css-and-javascript-motion-design-1bb9</guid>
      <description>&lt;p&gt;Animations are a powerful tool for enhancing the user experience on a website. They can be used to add visual interest, draw attention to important elements, and create a sense of interactivity and responsiveness. Animations can also help to guide users through a website and make it easier for them to navigate and understand the content.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Here's a simple example of an animation that can be used to draw attention to a call-to-action button:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.button{
    background-color: #3498db;
    color:#fff;
    padding:.75rem 1.5rem;
    border:none;
    border-radius: 5px;
    transition: transform 0.3s ease-in-out;
}

.button:hover{
    transform: scale(1.1);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this code, we have a call-to-action button with a blue background color. When the user hovers over the button, it scales up slightly to draw attention and indicate that it is clickable. This creates a subtle but effective animation that can help to increase conversions and engagement.&lt;/p&gt;

&lt;p&gt;Now, let's take a look at a more complex example. In this case, we'll use JavaScript to create a scroll-triggered animation that reveals content as the user scrolls down the page:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const revealElements = document.querySelectorAll('.reveal')

function revealOnScroll() {
    revealElements.forEach(element =&amp;gt; {
        const elementTop = element.getBoundingClientRect().top;
        const windowHeight = window.innerHeight
        if (elementTop &amp;lt; windowHeight - 100) {
            element.classList.add('visible')
        } else {
            element.classList.remove('visible')
        }
    });
}
window.addEventListener('scroll', revealOnScroll)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);

} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this code, we have a set of elements with the "reveal" class that are initially hidden using CSS. When the user scrolls down the page, a JavaScript function checks if each element is within the viewport and adds the "visible" class if it is. This triggers an animation that fades in and translates the element slightly to create a smooth reveal effect.&lt;/p&gt;

&lt;p&gt;This type of animation can be used to add interest and interactivity to long-form content such as blog posts or product pages. By breaking up the content into smaller sections that are revealed as the user scrolls, you can create a more engaging and memorable user experience.&lt;/p&gt;

&lt;p&gt;I hope these examples help to illustrate how animations can bring a website to life and provide some inspiration for your own projects!&lt;/p&gt;

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