<?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>DEV Community: Kevin Ramirez</title>
    <description>The latest articles on DEV Community by Kevin Ramirez (@kevinbism).</description>
    <link>https://dev.to/kevinbism</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%2F1260834%2Fa8b5a940-26cf-4e1b-a05b-8a0582c50843.jpeg</url>
      <title>DEV Community: Kevin Ramirez</title>
      <link>https://dev.to/kevinbism</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kevinbism"/>
    <language>en</language>
    <item>
      <title>Smarter CSS Targeting with :nth-child(of &lt;selector&gt;)</title>
      <dc:creator>Kevin Ramirez</dc:creator>
      <pubDate>Mon, 22 Sep 2025 10:19:00 +0000</pubDate>
      <link>https://dev.to/kevinbism/smarter-css-targeting-with-nth-childof--ph6</link>
      <guid>https://dev.to/kevinbism/smarter-css-targeting-with-nth-childof--ph6</guid>
      <description>&lt;p&gt;Most developers know about the &lt;code&gt;:nth-child()&lt;/code&gt; pseudo-class in CSS. It allows you to style elements based on their position inside a parent. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;li&lt;/span&gt;&lt;span class="nd"&gt;:nth-child&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="err"&gt;2&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This rule will select the second &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt; inside its parent. Pretty straightforward.&lt;/p&gt;

&lt;p&gt;But there’s a more powerful feature that many developers overlook: the &lt;code&gt;of &amp;lt;selector&amp;gt;&lt;/code&gt; syntax.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is &lt;code&gt;of &amp;lt;selector&amp;gt;&lt;/code&gt;?
&lt;/h2&gt;

&lt;p&gt;Normally, &lt;code&gt;:nth-child()&lt;/code&gt; counts &lt;em&gt;all&lt;/em&gt; child elements of a parent. But with the &lt;code&gt;of &amp;lt;selector&amp;gt;&lt;/code&gt; syntax, you can limit that count only to the elements that match a specific selector.&lt;/p&gt;

&lt;p&gt;In other words: instead of saying “give me the third child no matter what it is,” you can say “give me the third &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt; that matches a certain condition.”&lt;/p&gt;




&lt;h2&gt;
  
  
  Example: Targeting specific classes
&lt;/h2&gt;

&lt;p&gt;Let’s imagine a list where only some items are marked as important:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"important"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;First&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Second&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"important"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Third&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"important"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Fourth&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Fifth&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Sixth&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you write:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;li&lt;/span&gt;&lt;span class="nd"&gt;:nth-child&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;-n&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="err"&gt;3&lt;/span&gt; &lt;span class="nt"&gt;of&lt;/span&gt; &lt;span class="nc"&gt;.important&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will select only the first three list items that have the class &lt;code&gt;important&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Notice the difference:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Without &lt;code&gt;of &amp;lt;selector&amp;gt;&lt;/code&gt;, CSS would look at the raw order of all &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt; elements.&lt;/li&gt;
&lt;li&gt;With &lt;code&gt;of .important&lt;/code&gt;, CSS only counts the &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt; elements that match &lt;code&gt;.important&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can also use &lt;code&gt;:not()&lt;/code&gt; inside the &lt;code&gt;of &amp;lt;selector&amp;gt;&lt;/code&gt; to target the opposite case. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;li&lt;/span&gt;&lt;span class="nd"&gt;:nth-child&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;-n&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="err"&gt;3&lt;/span&gt; &lt;span class="nt"&gt;of&lt;/span&gt; &lt;span class="nd"&gt;:not&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;.important&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;green&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will select the first three &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt; elements &lt;strong&gt;that do not have&lt;/strong&gt; the class &lt;code&gt;important&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Notice how flexible this becomes: instead of styling everything or adding extra classes, you can precisely define the subset of elements you want.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why is this useful?
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;of &amp;lt;selector&amp;gt;&lt;/code&gt; syntax is great when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You want to style only the first or last few elements of a certain type.&lt;/li&gt;
&lt;li&gt;You’re working with lists or grids where not every child matches the same criteria.&lt;/li&gt;
&lt;li&gt;You want more control without having to add extra classes in your HTML.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It’s a cleaner way to target elements without increasing the complexity of your markup.&lt;/p&gt;




&lt;h2&gt;
  
  
  Browser support
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;of &amp;lt;selector&amp;gt;&lt;/code&gt; syntax is relatively new, but it has good support in modern browsers. If you’re working on a project that needs to support older browsers, make sure to test or provide fallbacks.&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;:nth-child()&lt;/code&gt; pseudo-class is already powerful, but the &lt;code&gt;of &amp;lt;selector&amp;gt;&lt;/code&gt; syntax takes it to the next level. By combining position-based selection with specific conditions, you can write CSS that is both expressive and flexible.&lt;/p&gt;

&lt;p&gt;Next time you need to target only a subset of elements in a list or grid, remember that &lt;code&gt;:nth-child(of &amp;lt;selector&amp;gt;)&lt;/code&gt; might be the perfect tool.&lt;/p&gt;




&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-child" rel="noopener noreferrer"&gt;MDN Docs: &lt;code&gt;:nth-child()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.w3.org/TR/selectors-4/#nth-child-pseudo" rel="noopener noreferrer"&gt;CSS Selectors Level 4 Specification&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>frontend</category>
      <category>ui</category>
    </item>
    <item>
      <title>Recreating Apple's Liquid Glass Effect with Pure CSS ✨</title>
      <dc:creator>Kevin Ramirez</dc:creator>
      <pubDate>Tue, 10 Jun 2025 21:07:53 +0000</pubDate>
      <link>https://dev.to/kevinbism/recreating-apples-liquid-glass-effect-with-pure-css-3gpl</link>
      <guid>https://dev.to/kevinbism/recreating-apples-liquid-glass-effect-with-pure-css-3gpl</guid>
      <description>&lt;p&gt;Yesterday, Apple dropped something unexpectedly beautiful at WWDC 2025. While we were all waiting for the next AI breakthrough, Tim Cook surprised everyone with iOS 26, featuring the new "Liquid Glass" design language. The design refresh is inspired by Apple's VR headset, the Vision Pro, bringing translucent menus, glossy icons and rounded controls across all Apple devices.&lt;/p&gt;

&lt;p&gt;But here's the thing about us developers – when Apple shows us something shiny and new, we can't help but think: "I bet I could build that with CSS." 🤓&lt;/p&gt;

&lt;p&gt;So naturally, instead of waiting for iOS 26, I decided to recreate Apple's Liquid Glass effect using nothing but HTML and CSS. No JavaScript, no complex frameworks – just good old-fashioned web magic.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Makes Liquid Glass So Special?
&lt;/h2&gt;

&lt;p&gt;Apple's Liquid Glass uses real-time rendering and dynamically reacts to movement with specular highlights, creating an interface that feels alive and responsive. The features include shiny, reflective, and transparent visual interface elements that give the software a more "glassy" look and feel.&lt;/p&gt;

&lt;p&gt;The key is combining multiple CSS techniques to achieve that perfect balance of transparency, depth, and that subtle "liquid" quality that makes everything feel premium.&lt;/p&gt;

&lt;h2&gt;
  
  
  Breaking Down the CSS Magic
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. The Foundation: Creating Glass
&lt;/h3&gt;

&lt;p&gt;The heart of the effect lies in combining several CSS properties:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.glass&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;relative&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0.15&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="py"&gt;backdrop-filter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;blur&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;2px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;saturate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;180%&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0.8&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;box-shadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;8px&lt;/span&gt; &lt;span class="m"&gt;32px&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;31&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;38&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;135&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0.2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; 
              &lt;span class="nb"&gt;inset&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;4px&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0.3&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's what each property does:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;backdrop-filter: blur()&lt;/code&gt; creates that frosted glass blur effect&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;rgba()&lt;/code&gt; backgrounds provide semi-transparent layers&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;inset box-shadow&lt;/code&gt; adds inner glow and depth&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;border: rgba()&lt;/code&gt; creates subtle glass-like edges&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. The Liquid Touch: Pseudo-element Magic
&lt;/h3&gt;

&lt;p&gt;The real secret sauce is in the &lt;code&gt;::after&lt;/code&gt; pseudo-element that creates the liquid shine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.glass&lt;/span&gt;&lt;span class="nd"&gt;::after&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;absolute&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;backdrop-filter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;blur&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1px&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;box-shadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;inset&lt;/span&gt; &lt;span class="m"&gt;-10px&lt;/span&gt; &lt;span class="m"&gt;-8px&lt;/span&gt; &lt;span class="m"&gt;0px&lt;/span&gt; &lt;span class="m"&gt;-11px&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
              &lt;span class="nb"&gt;inset&lt;/span&gt; &lt;span class="m"&gt;0px&lt;/span&gt; &lt;span class="m"&gt;-9px&lt;/span&gt; &lt;span class="m"&gt;0px&lt;/span&gt; &lt;span class="m"&gt;-8px&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.6&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;z-index&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;-1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;blur&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;drop-shadow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;10px&lt;/span&gt; &lt;span class="m"&gt;4px&lt;/span&gt; &lt;span class="m"&gt;6px&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;brightness&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;115%&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates those subtle highlights and reflections that make the glass appear "liquid" – as if light is flowing across the surface.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cross-Browser Compatibility
&lt;/h2&gt;

&lt;p&gt;The effect works great on modern browsers that support &lt;code&gt;backdrop-filter&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Chrome, Firefox, Safari, Edge&lt;/li&gt;
&lt;li&gt;❌ Internet Explorer (but honestly, when was the last time you worried about IE?)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For older browsers, you can provide fallback styles or use a polyfill.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try It Yourself
&lt;/h2&gt;

&lt;p&gt;Want to see it in action? I've put together a live demo that you can experiment with:&lt;/p&gt;

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

&lt;h2&gt;
  
  
  What's Next?
&lt;/h2&gt;

&lt;p&gt;This is just the beginning! The liquid glass effect opens up so many possibilities for modern web design. You could easily adapt this technique for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Navigation menus&lt;/li&gt;
&lt;li&gt;Modal dialogs
&lt;/li&gt;
&lt;li&gt;Dashboard widgets&lt;/li&gt;
&lt;li&gt;Mobile app interfaces&lt;/li&gt;
&lt;li&gt;Landing page sections&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The key is finding the right balance between visual appeal and usability – just like Apple did.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;While we wait for iOS 26 to hit our devices, we can already start bringing some of that Apple magic to the web. Sometimes the best way to understand a new design trend is to roll up your sleeves and build it yourself.&lt;/p&gt;

&lt;p&gt;The beauty of CSS is that it gives us the power to recreate even the most sophisticated design systems. Who knows? Maybe your next project will be the one that makes users do a double-take and wonder, "Wait, is this a native app or a website?"&lt;/p&gt;




&lt;h2&gt;
  
  
  🔗 Resources &amp;amp; References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://kevinbism.github.io/liquid-glass-effect/" rel="noopener noreferrer"&gt;Live Demo&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/kevinbism/liquid-glass-effect" rel="noopener noreferrer"&gt;GitHub Repository&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://codepen.io/kevinbism/pen/vEOpvjw" rel="noopener noreferrer"&gt;CodePen Example&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://css.glass/" rel="noopener noreferrer"&gt;Glassmorphism Generator&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Background image from &lt;a href="https://unsplash.com" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Made with ❤️ and CSS magic&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;What do you think about Apple's new design direction? Are you planning to experiment with liquid glass effects in your projects? Let me know in the comments below! 👇&lt;/p&gt;

</description>
      <category>css</category>
      <category>design</category>
      <category>webdev</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Waving Lines of Code: Creating Hypnotic Canvas Animations with JavaScript 🌊</title>
      <dc:creator>Kevin Ramirez</dc:creator>
      <pubDate>Tue, 28 Jan 2025 17:14:18 +0000</pubDate>
      <link>https://dev.to/kevinbism/waving-lines-of-code-creating-hypnotic-canvas-animations-with-javascript-3l11</link>
      <guid>https://dev.to/kevinbism/waving-lines-of-code-creating-hypnotic-canvas-animations-with-javascript-3l11</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgagro6i73fjmz1sg5umq.gif" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgagro6i73fjmz1sg5umq.gif" alt="Dancing Wave GIF" width="200" height="200"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;em&gt;(A little preview of what we're creating - but way more hypnotic!)&lt;/em&gt;&lt;/p&gt;



&lt;p&gt;Have you ever wanted to make your website background say "ooooh, fancy!" without actually saying it? Let's create some smooth, undulating line waves using JavaScript's Canvas API. It's easier than you think, and the result looks like digital seaweed dancing in the virtual ocean!&lt;/p&gt;
&lt;h2&gt;
  
  
  The Magic Ingredients 🧙
&lt;/h2&gt;

&lt;p&gt;We'll need just three basic components:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A &lt;code&gt;&amp;lt;canvas&amp;gt;&lt;/code&gt; element as our digital sketchpad&lt;/li&gt;
&lt;li&gt;Some wave configuration magic&lt;/li&gt;
&lt;li&gt;An animation loop to make it all move
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Let's start by creating our canvas&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;canvas&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;canvas&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;classList&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;wave&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;2d&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Set dimensions to match viewport&lt;/span&gt;
&lt;span class="nx"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;130&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;height&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;innerHeight&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpstuo6dam4bd2ucq3w81.gif" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpstuo6dam4bd2ucq3w81.gif" alt="Wait, what?" width="480" height="204"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;em&gt;("Wait, why 130px width?" - Because we want vertical waves!)&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Wave Configuration 🌊
&lt;/h2&gt;

&lt;p&gt;Here's where the fun begins. We create multiple waves with random properties:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;waves&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;length&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;65&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
  &lt;span class="na"&gt;length&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;random&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.002&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.005&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;amplitude&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;random&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;frequency&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;random&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.02&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.005&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's break down these wave properties:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;x&lt;/code&gt;: center position (65 = middle of 130px canvas)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;length&lt;/code&gt;: how squiggly the wave is&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;amplitude&lt;/code&gt;: wave height&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;frequency&lt;/code&gt;: how fast it undulates&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Animation Loop 🔄
&lt;/h2&gt;

&lt;p&gt;This is where we bring our waves to life:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;requestAnimationFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;clearRect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="nx"&gt;waves&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;wave&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Drawing magic happens here&lt;/span&gt;
    &lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;beginPath&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;moveTo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;wave&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Create wave path&lt;/span&gt;
    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;canvas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lineTo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nx"&gt;wave&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;y&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;wave&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;increments&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;wave&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;amplitude&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nx"&gt;y&lt;/span&gt;
      &lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stroke&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nx"&gt;increments&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;wave&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;frequency&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgd1dhgi1klibyavkvi61.gif" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgd1dhgi1klibyavkvi61.gif" alt="Wave a minute" width="240" height="320"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;em&gt;(Our code making waves (literally))&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  See It in Action 🎬
&lt;/h2&gt;

&lt;p&gt;Check out this CodePen demo to see the final result. Feel free to play with the values!&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Level Up! 🚀
&lt;/h2&gt;

&lt;p&gt;Want to make it even cooler? Try:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Adding mouse interaction&lt;/li&gt;
&lt;li&gt;Changing colors dynamically&lt;/li&gt;
&lt;li&gt;Creating horizontal waves&lt;/li&gt;
&lt;li&gt;Adding gradient effects&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feddcaytme5a3ntdgaxky.gif" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feddcaytme5a3ntdgaxky.gif" alt="Cat down" width="480" height="480"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;em&gt;(You after customizing these waves)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Remember: The best way to learn is to break things! Try changing values randomly and see what happens.&lt;/p&gt;

&lt;p&gt;Happy coding! 🌊💻&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>canvas</category>
      <category>animation</category>
      <category>webdev</category>
    </item>
    <item>
      <title>CSS Animations with display: none 🤯🤔</title>
      <dc:creator>Kevin Ramirez</dc:creator>
      <pubDate>Wed, 21 Aug 2024 10:49:15 +0000</pubDate>
      <link>https://dev.to/kevinbism/css-animation-with-display-none-4pan</link>
      <guid>https://dev.to/kevinbism/css-animation-with-display-none-4pan</guid>
      <description>&lt;p&gt;CSS animations are fundamental to modern web development. But one of the biggest problems in CSS has been animating the property &lt;code&gt;display: none&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So far, it has not been possible to animate this property because it is a sort of switch, either on or off. So far...&lt;/p&gt;

&lt;p&gt;Yes, because there are currently some tricks to be able to create animations with &lt;code&gt;display: none&lt;/code&gt; and you can use them from now.&lt;/p&gt;




&lt;h2&gt;
  
  
  A new way to animate &lt;code&gt;display: none&lt;/code&gt;
&lt;/h2&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnen1octukkrliy3n8s3y.gif" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnen1octukkrliy3n8s3y.gif" alt="Renzi meme" width="576" height="288"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At first glance it looks like a normal transition effect with opacity. But if you look closely at the code there are some features to consider.&lt;/p&gt;

&lt;p&gt;This is the code we are going to inspect:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.block&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;max-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;500px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50px&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#29C38A&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;box-sized&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;border-box&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;opacity&lt;/span&gt; &lt;span class="m"&gt;.3s&lt;/span&gt; &lt;span class="n"&gt;ease&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;display&lt;/span&gt; &lt;span class="m"&gt;.3s&lt;/span&gt; &lt;span class="n"&gt;ease&lt;/span&gt; &lt;span class="n"&gt;allow-discrete&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* &amp;lt;-- check this line */&lt;/span&gt;

  &lt;span class="err"&gt;&amp;amp;.open&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;block&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="err"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;@starting-style&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="c"&gt;/* &amp;lt;-- and this line */&lt;/span&gt;
  &lt;span class="nc"&gt;.block.open&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  transition-behavior: allow-discrete
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;transition-behavior: allow-discrete&lt;/code&gt; property manages how discrete properties like &lt;code&gt;display&lt;/code&gt; and &lt;code&gt;content-visibility&lt;/code&gt; animate. Normally, these properties flip values at the 50% mark of an animation. However, when transitioning to or from &lt;code&gt;display: none&lt;/code&gt; or &lt;code&gt;content-visibility: hidden&lt;/code&gt;, the content remains visible throughout, flipping to the visible state at 0% or to &lt;code&gt;none&lt;/code&gt; at 100%.&lt;/p&gt;

&lt;h3&gt;
  
  
  @starting-style
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;@starting-style&lt;/code&gt; CSS rule is used to enable transitions on an element's first appearance or when its display changes from &lt;code&gt;none&lt;/code&gt; to another value. Normally, CSS transitions don't trigger on initial style updates, so &lt;code&gt;@starting-style&lt;/code&gt; defines the starting values for properties to transition from.&lt;/p&gt;

&lt;p&gt;This rule is especially useful for creating smooth entry and exit animations for elements like popovers, modals, or anything added or removed from the DOM. It can be used as a standalone block or nested within an existing ruleset. The &lt;code&gt;@starting-style&lt;/code&gt; ensures that the element transitions from the specified starting values when it first appears.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Using &lt;code&gt;transition-behavior: allow-discrete&lt;/code&gt; and &lt;code&gt;@starting-style&lt;/code&gt; opens up new possibilities for animating elements that were previously challenging, like those with &lt;code&gt;display: none&lt;/code&gt;. These tools make it easier to create smooth and visually appealing transitions, improving the user experience without needing complicated workarounds. By allowing seamless animations when elements first appear or disappear, they bring more flexibility and control to web design, making your interfaces more dynamic and engaging.&lt;/p&gt;

&lt;h3&gt;
  
  
  References
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/transition-behavior" rel="noopener noreferrer"&gt;transition-behavior mdn web docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/@starting-style" rel="noopener noreferrer"&gt;@starting-style mdn web docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://codepen.io/argyleink/pen/qBGOamz" rel="noopener noreferrer"&gt;Codepen example with &lt;code&gt;&amp;lt;dialog&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;popover&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Coding the Perfect Documentation: Deciding Between 🚀 Vitepress and ✨ Astro Starlight</title>
      <dc:creator>Kevin Ramirez</dc:creator>
      <pubDate>Thu, 22 Feb 2024 14:58:44 +0000</pubDate>
      <link>https://dev.to/kevinbism/coding-the-perfect-documentation-deciding-between-vitepress-and-astro-starlight-2i11</link>
      <guid>https://dev.to/kevinbism/coding-the-perfect-documentation-deciding-between-vitepress-and-astro-starlight-2i11</guid>
      <description>&lt;p&gt;&lt;strong&gt;Vitepress&lt;/strong&gt; and &lt;strong&gt;Astro Starlight&lt;/strong&gt; are two static site generators that offer high performance, support for &lt;strong&gt;markdown&lt;/strong&gt;, and the ability to &lt;strong&gt;use components within pages&lt;/strong&gt;. In this article, I want to compare the two tools and see what their strengths and weaknesses are, and which one is better to use depending on the use case.&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Vitepress&lt;/li&gt;
&lt;li&gt;Astro Starlight&lt;/li&gt;
&lt;li&gt;Which one choose?&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;li&gt;References&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Vitepress 🚀
&lt;/h2&gt;

&lt;p&gt;VitePress is a modern static site generator (SSG) that offers simplicity, speed, and seamless integration with Vue-based applications. Here are the key points:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Powered by Vite and Vue.js&lt;/strong&gt;: VitePress leverages the lightning-fast build tool &lt;strong&gt;Vite&lt;/strong&gt; and the popular JavaScript framework &lt;strong&gt;Vue.js&lt;/strong&gt;. This combination ensures rapid development and optimal performance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Minimalistic Approach&lt;/strong&gt;: VitePress follows a minimalistic philosophy. It aims to keep things simple, making it an excellent choice for straightforward documentation sites, blogs, or personal projects.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Customization Flexibility&lt;/strong&gt;: While VitePress provides a default theme, it encourages customization through Vue (using custom themes) or Vite (leveraging Vite’s configuration options and plugins). For users who stick with the default theme, it’s almost a drop-in replacement with minor adjustments. However, if you’re building a fully custom site, VitePress remains flexible.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Pros:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Better Developer Experience (DX)&lt;/strong&gt;: VitePress offers an improved development experience compared to traditional SSGs. The fast build times and hot module replacement (HMR) during development enhance productivity.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Performance Boost&lt;/strong&gt;: Thanks to Vite’s asynchronous loading of chunks and automatic CSS extraction, VitePress achieves impressive performance. It extracts CSS used by modules into separate files, reducing page load times.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Standardization with Vite&lt;/strong&gt;: VitePress aligns seamlessly with standard Vite-based Vue applications. This consistency simplifies development workflows and ensures compatibility.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Cons
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Short-Term Confusion&lt;/strong&gt;: Since VitePress is a newer player in the SSG landscape, users accustomed to tutorials and integrations targeting VuePress 1 might experience initial confusion. However, with the recent switch to Vue 3, major upgrades shouldn’t catch users off guard.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Astro Starlight ✨
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Astro Starlight&lt;/strong&gt; is a full-featured, eco-friendly documentation theme built on the &lt;strong&gt;Astro&lt;/strong&gt; framework. It caters to developers and content creators who want to build stellar documentation websites. Here are the key points:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Powered by Astro&lt;/strong&gt;: Starlight leverages the full power and performance of Astro, a modern static site generator. Astro’s asynchronous loading of chunks and seamless integration with Vue.js contribute to its impressive speed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Feature-Rich and Accessible&lt;/strong&gt;: Starlight offers comprehensive features for enhanced accessibility and functionality. Easy navigation and robust search ensure quick access to content. Multilingual support promotes inclusivity. Clear typography and code highlighting improve readability. Dark and light modes accommodate user preferences, enhancing the overall experience.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Customization Flexibility&lt;/strong&gt;: Starlight offers versatile customization options with built-in frontmatter validation, ensuring TypeScript type-safety for frontmatter. As a framework-agnostic solution, it provides flexibility for integration with various UI libraries, including but not limited to React, Vue, Svelte, Solid, and more, allowing users to tailor the platform to their preferences and needs.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Pros:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Markdown Components&lt;/strong&gt;: Starlight supports components in Markdown (similar to MDX but without JSX), making it easy to create dynamic content.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vite-Powered&lt;/strong&gt;: Powered by Vite, Starlight benefits from fast development builds and hot module replacement (HMR).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Cons:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Learning Curve&lt;/strong&gt;: As a newer player in the static site generator landscape, Astro might have a learning curve for those accustomed to other tools. However, its benefits outweigh the initial challenges.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Which one choose?
&lt;/h2&gt;

&lt;p&gt;The comparison between Vitepress and Astro Starlight largely depends on the type of website you want to build. If you want to &lt;strong&gt;create a simple website&lt;/strong&gt; with a lot of markdown content and few interactive components, Vitepress might be a good choice as it offers a fast and efficient solution based on Vue.js. If you want to &lt;strong&gt;create a more complex website&lt;/strong&gt; with different UI frameworks and dynamic components, Astro Starlight might be more suitable as it offers greater flexibility and control over page rendering.&lt;/p&gt;

&lt;p&gt;In terms of performance, both tools offer advantages. Vitepress leverages the speed of Vite to provide instant server startup and fast builds. Astro Starlight, on the other hand, optimizes pages to minimize the JavaScript code sent to the browser and load only necessary components. Both tools generate static HTML pages that can be easily indexed by search engines and offer a great user experience.&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Vitepress and Astro Starlight are two valid and modern static site generators. The choice between the two depends on the type of website you want to create and your personal preferences. Both tools offer interesting features and high performance but also significant differences in terms of approach and flexibility.&lt;/p&gt;

&lt;h3&gt;
  
  
  References
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://vitepress.dev/" rel="noopener noreferrer"&gt;Vitepress Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://starlight.astro.build/" rel="noopener noreferrer"&gt;Starlight Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/charlesw_dev/ship-a-beautiful-docs-site-with-vitepress-and-render-3hc2"&gt;How to build a beautiful docs site with VitePress and Render&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/mrrobot/publishing-documentation-with-astro-starlight-691"&gt;Publishing documentation with Astro Starlight&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>discuss</category>
      <category>webdev</category>
      <category>productivity</category>
      <category>documentation</category>
    </item>
    <item>
      <title>Mastering the Art of Nesting in CSS: Before and Now</title>
      <dc:creator>Kevin Ramirez</dc:creator>
      <pubDate>Mon, 22 Jan 2024 10:29:33 +0000</pubDate>
      <link>https://dev.to/kevinbism/mastering-the-art-of-nesting-in-css-before-and-now-14ep</link>
      <guid>https://dev.to/kevinbism/mastering-the-art-of-nesting-in-css-before-and-now-14ep</guid>
      <description>&lt;p&gt;In the ever-evolving realm of web development, the way we structure and organize our stylesheets plays a pivotal role in creating clean and maintainable code. One sought-after feature that has been a game-changer, especially for preprocessors like Sass and Less, is nesting. In this post, we'll dive into the world of nesting, exploring its benefits and examining how it has evolved up to 2024.&lt;/p&gt;

&lt;h2&gt;
  
  
  Before: Nesting in Preprocessors (Sass)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sass"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Before: Nesting in Sass&lt;/span&gt;

&lt;span class="c1"&gt;// Define styles for a container&lt;/span&gt;
&lt;span class="nc"&gt;.container&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="err"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="err"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// Nest styles for the header inside the container&lt;/span&gt;
  &lt;span class="nt"&gt;header&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#333&lt;/span&gt;&lt;span class="err"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#fff&lt;/span&gt;&lt;span class="err"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="mi"&gt;.5em&lt;/span&gt;&lt;span class="err"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// Nest styles for links inside the header&lt;/span&gt;
    &lt;span class="nt"&gt;a&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;text-decoration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="err"&gt;;&lt;/span&gt;
      &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#ff7e5f&lt;/span&gt;&lt;span class="err"&gt;;&lt;/span&gt;
    &lt;span class="err"&gt;}&lt;/span&gt;
  &lt;span class="err"&gt;}&lt;/span&gt;

  &lt;span class="c1"&gt;// Nest styles for the main content&lt;/span&gt;
  &lt;span class="nc"&gt;.main-content&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;margin-top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="err"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="mi"&gt;.2em&lt;/span&gt;&lt;span class="err"&gt;;&lt;/span&gt;
  &lt;span class="err"&gt;}&lt;/span&gt;
&lt;span class="err"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nesting in preprocessors like Sass allows us to encapsulate styles, providing a clearer, more organized structure. However, the landscape is changing, and it's time to explore what the native CSS has to offer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Now: Native CSS
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* Now: Native CSS */&lt;/span&gt;

&lt;span class="c"&gt;/* Define styles for a container */&lt;/span&gt;
&lt;span class="nc"&gt;.container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c"&gt;/* Styles for the header inside the container */&lt;/span&gt;
  &lt;span class="err"&gt;header&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#333&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.5em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c"&gt;/* Styles for links inside the header */&lt;/span&gt;
    &lt;span class="err"&gt;a&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;
      &lt;span class="nl"&gt;text-decoration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#ff7e5f&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="err"&gt;}&lt;/span&gt;

  &lt;span class="c"&gt;/* Styles for the main content inside the container */&lt;/span&gt;
  &lt;span class="nc"&gt;.main-content&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;margin-top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.2em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="err"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's reflect on the advantages of nesting and how it can shape the future of our stylesheets. This is a very simple example of what css can do. To learn more about all the features of nesting in css there is an &lt;a href="https://developer.chrome.com/docs/css-ui/css-nesting" rel="noopener noreferrer"&gt;article in Chrome for Developers.&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Benefits of Nesting: Why It Matters
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Readability:&lt;/strong&gt; Nesting enhances code readability by mirroring the HTML structure, making it easier to understand the relationship between elements and their styles.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Maintainability:&lt;/strong&gt; Updates and changes become more straightforward as nested styles reflect the hierarchy of your HTML, reducing the likelihood of errors.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code Organization:&lt;/strong&gt; Nesting allows for a more organized and modular approach to styling, facilitating a cleaner and scalable codebase.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Looking Ahead: The Future of CSS Nesting
&lt;/h2&gt;

&lt;p&gt;As of now, native CSS is yet to embrace nesting fully, but the web development landscape is dynamic. Keep an eye on emerging updates, as the demand for a more concise and expressive CSS syntax continues to grow.&lt;/p&gt;

&lt;p&gt;In conclusion, whether you're harnessing the power of nesting in preprocessors or eagerly anticipating native support in CSS, the benefits are undeniable. Let's celebrate the progress made and look forward to an even more streamlined and efficient future in web development. Happy coding!&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Unleashing the Power of :has() in CSS: A Selective Journey✨</title>
      <dc:creator>Kevin Ramirez</dc:creator>
      <pubDate>Fri, 19 Jan 2024 11:50:04 +0000</pubDate>
      <link>https://dev.to/kevinbism/unleashing-the-power-of-has-in-css-a-selective-journey-fog</link>
      <guid>https://dev.to/kevinbism/unleashing-the-power-of-has-in-css-a-selective-journey-fog</guid>
      <description>&lt;p&gt;🚀 Hey Dev Community! Have you ever found yourself wishing CSS had a more robust way to select elements based on their content or structure? Well, your developer dreams are about to come true with the lesser-known &lt;code&gt;:has()&lt;/code&gt; pseudo-class! 🎉&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding the Magic of :has()
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;:has()&lt;/code&gt; pseudo-class introduces a new level of selectivity to CSS, enabling you to target elements based on their descendants. This opens the door to more precise styling, reducing the need for complex class names or additional HTML structure.&lt;/p&gt;

&lt;p&gt;Let's dive into some examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"#"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;I'm a link inside a div!&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"special"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Special List Item&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Ordinary List Item&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed cursus purus vitae tellus sodales.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;This paragraph is empty.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* Selecting a div containing an anchor tag */&lt;/span&gt;
&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="nd"&gt;:has&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="m"&gt;#3498db&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* Styling a list item with a specific class */&lt;/span&gt;
&lt;span class="nt"&gt;li&lt;/span&gt;&lt;span class="nd"&gt;:has&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;.special&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#ffcc00&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;bold&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* Applying styles to paragraphs with more than 100 words */&lt;/span&gt;
&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="nd"&gt;:has&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nd"&gt;:not&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nd"&gt;:empty&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="nd"&gt;:after&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#2ecc71&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;italic&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Breaking Down the Examples
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Selecting a div containing an anchor tag: The &lt;code&gt;div:has(a)&lt;/code&gt; rule adds a border and padding to any div that contains an anchor (&lt;code&gt;a&lt;/code&gt;) tag.&lt;/li&gt;
&lt;li&gt;Styling a list item with a specific class: The &lt;code&gt;li:has(.special)&lt;/code&gt; rule applies styles to list items with the class special, making them stand out.&lt;/li&gt;
&lt;li&gt;Applying styles to paragraphs with more than 100 words: The &lt;code&gt;p:has(:not(:empty):after)&lt;/code&gt; rule targets paragraphs with content (not empty) and more than 100 words, applying a unique style.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;:has()&lt;/code&gt; pseudo-class is a powerful tool in the CSS arsenal, offering a more expressive way to style elements based on their internal structure. As you experiment with this feature, share your thoughts, creative use cases, and any cool discoveries below! 👇&lt;/p&gt;

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