<?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: codingdudecom</title>
    <description>The latest articles on DEV Community by codingdudecom (@codingdudecom).</description>
    <link>https://dev.to/codingdudecom</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%2F375155%2F0a59dbaa-2cba-4cbc-a4d9-ec96e8572902.jpeg</url>
      <title>DEV Community: codingdudecom</title>
      <link>https://dev.to/codingdudecom</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/codingdudecom"/>
    <language>en</language>
    <item>
      <title>How to Draw a Spiral with JavaScript</title>
      <dc:creator>codingdudecom</dc:creator>
      <pubDate>Sun, 26 Oct 2025 16:59:33 +0000</pubDate>
      <link>https://dev.to/codingdudecom/how-to-draw-a-spiral-with-javascript-4n9a</link>
      <guid>https://dev.to/codingdudecom/how-to-draw-a-spiral-with-javascript-4n9a</guid>
      <description>&lt;p&gt;In this tutorial, we'll explore how to draw a spiral using JavaScript and the HTML5 &lt;code&gt;&amp;lt;canvas&amp;gt;&lt;/code&gt; element. We'll break down the code and concepts, making it easy for beginners to follow along.&lt;/p&gt;

&lt;p&gt;For those who want to jump right in and play with a finished product, check out this &lt;a href="https://www.coding-dude.com/wp/spiral/" rel="noopener noreferrer"&gt;online spiral maker&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up the Canvas
&lt;/h2&gt;

&lt;p&gt;First, we need an HTML file with a &lt;code&gt;&amp;lt;canvas&amp;gt;&lt;/code&gt; element. This is where our spiral will be drawn.&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="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;JS Spiral&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;canvas&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"spiral-canvas"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/canvas&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"spiral.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The JavaScript Logic
&lt;/h2&gt;

&lt;p&gt;Now, let's dive into the JavaScript. The core idea is to draw a series of lines that rotate and expand from the center.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Getting the Canvas and Context
&lt;/h3&gt;

&lt;p&gt;We start by getting a reference to our canvas and its 2D drawing context.&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;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;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;spiral-canvas&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;ctx&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. The Drawing Function
&lt;/h3&gt;

&lt;p&gt;We'll create a function that takes parameters like &lt;code&gt;sides&lt;/code&gt;, &lt;code&gt;size&lt;/code&gt;, &lt;code&gt;gap&lt;/code&gt;, and &lt;code&gt;color&lt;/code&gt;.&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;drawSpiral&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;sides&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;size&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;gap&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Set canvas dimensions&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="nx"&gt;size&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;size&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// Clear the canvas&lt;/span&gt;
    &lt;span class="nx"&gt;ctx&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="c1"&gt;// Move to the center&lt;/span&gt;
    &lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;save&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;translate&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="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&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="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="nx"&gt;ctx&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;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;strokeStyle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;lineWidth&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;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;angle&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="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;currentGap&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="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;i&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;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&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="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;sides&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;angle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&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="nx"&gt;PI&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nx"&gt;sides&lt;/span&gt;&lt;span class="p"&gt;)&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;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;sides&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;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;angle&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mf"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="nx"&gt;currentGap&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;gap&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;100&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;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;cos&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;angle&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;currentGap&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;y&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;angle&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;currentGap&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="nx"&gt;ctx&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;x&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;ctx&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;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;restore&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;
  
  
  Breaking Down &lt;code&gt;drawSpiral&lt;/code&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;&lt;code&gt;canvas.width = size;&lt;/code&gt; and &lt;code&gt;canvas.height = size;&lt;/code&gt;&lt;/strong&gt;: We set the canvas dimensions based on the desired &lt;code&gt;size&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;&lt;code&gt;ctx.translate(...)&lt;/code&gt;&lt;/strong&gt;: This moves the drawing origin to the center of the canvas, so our spiral starts from the middle.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;The Loop&lt;/strong&gt;: The &lt;code&gt;for&lt;/code&gt; loop is where the magic happens. In each iteration:

&lt;ul&gt;
&lt;li&gt;  We calculate the &lt;code&gt;angle&lt;/code&gt; to determine the direction of the line. If &lt;code&gt;sides&lt;/code&gt; are specified, it creates a polygonal spiral.&lt;/li&gt;
&lt;li&gt;  We increment &lt;code&gt;currentGap&lt;/code&gt; to make the spiral expand outwards.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;Math.cos(angle)&lt;/code&gt; and &lt;code&gt;Math.sin(angle)&lt;/code&gt; are used to get the &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt; coordinates on a circle.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;ctx.lineTo(x, y)&lt;/code&gt; draws a line to the new point.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;  &lt;strong&gt;&lt;code&gt;ctx.stroke()&lt;/code&gt;&lt;/strong&gt;: This actually draws the spiral on the canvas.&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Drawing the Initial Spiral
&lt;/h3&gt;

&lt;p&gt;To see our spiral, we need to call the &lt;code&gt;drawSpiral&lt;/code&gt; function with some initial values.&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="nf"&gt;drawSpiral&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;400&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#000000&lt;/span&gt;&lt;span class="dl"&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 draw a simple, round spiral.&lt;/p&gt;

&lt;h2&gt;
  
  
  Interactivity (Optional)
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://www.coding-dude.com/wp/spiral/" rel="noopener noreferrer"&gt;spiral maker example&lt;/a&gt; includes sliders to change the spiral's properties in real-time. This is done by adding event listeners to the input elements and redrawing the spiral whenever a value changes.&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;sizeSlider&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;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;size&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;sizeSlider&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;input&lt;/span&gt;&lt;span class="dl"&gt;'&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="c1"&gt;// Redraw the spiral with the new size&lt;/span&gt;
    &lt;span class="nf"&gt;drawSpiral&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="nf"&gt;parseInt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;sizeSlider&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#000000&lt;/span&gt;&lt;span class="dl"&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;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;And that's it! You've learned the basics of drawing a spiral with JavaScript. You can expand on this by adding more controls, colors, and even animations.&lt;/p&gt;

&lt;p&gt;For a more advanced and feature-rich example, be sure to check out the &lt;a href="https://www.coding-dude.com/wp/spiral/" rel="noopener noreferrer"&gt;Spiral Maker&lt;/a&gt; on my blog.&lt;/p&gt;

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

&lt;p&gt;...what's next?&lt;br&gt;
&lt;strong&gt;Spiral Text Generator&lt;/strong&gt;: If you want to write text on the spiral path, use this &lt;a href="https://www.mockofun.com/template/spiral-text/" rel="noopener noreferrer"&gt;spiral text generator&lt;/a&gt; online free. &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>canvas</category>
    </item>
    <item>
      <title>CSS Dotted Background</title>
      <dc:creator>codingdudecom</dc:creator>
      <pubDate>Fri, 16 May 2025 17:39:22 +0000</pubDate>
      <link>https://dev.to/codingdudecom/css-dotted-background-4m20</link>
      <guid>https://dev.to/codingdudecom/css-dotted-background-4m20</guid>
      <description>&lt;p&gt;READ ORIGINAL HERE: &lt;a href="https://www.coding-dude.com/wp/css/css-dotted-background/" rel="noopener noreferrer"&gt;CSS Dotted Background&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This tutorial breaks down how to create a &lt;strong&gt;CSS dotted pattern&lt;/strong&gt; using SVG to achieve a halftone &lt;strong&gt;dotted CSS background&lt;/strong&gt;. Halftoning is a reprographic technique that simulates continuous-tone imagery through the use of a &lt;strong&gt;dotted grid background&lt;/strong&gt;, varying in size or spacing to generate a gradient-like effect. We’ll create this &lt;strong&gt;dot background CSS&lt;/strong&gt; effect by combining gradients, patterns, and SVG filters to craft a stunning &lt;strong&gt;dots background CSS&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Full SVG Code (for Reference)
&lt;/h2&gt;

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

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; The main SVG element in the code above is styled to be hidden (&lt;code&gt;style="position:absolute; top:-9999px; left:-9999px; opacity:0; pointer-events:none;"&lt;/code&gt;). This is because its sole purpose is to define the filter components (gradients, patterns, and the filter itself). The actual visual effect will be applied to a separate HTML element using CSS: &lt;code&gt;filter: url(#blendAndThresholdFilter)&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Creating a &lt;strong&gt;dotted CSS background&lt;/strong&gt; is a common design requirement, ranging from simple repeating &lt;strong&gt;dots background CSS&lt;/strong&gt; to more complex visual effects. For a basic &lt;strong&gt;dotted grid background&lt;/strong&gt;, CSS offers straightforward solutions using &lt;code&gt;background-image&lt;/code&gt; with &lt;code&gt;radial-gradient&lt;/code&gt; and &lt;code&gt;background-repeat&lt;/code&gt;. You can easily generate a uniform &lt;strong&gt;css dotted pattern&lt;/strong&gt; this way, giving your elements a clean, geometric look. This approach is excellent for static, repeating &lt;strong&gt;dot background css&lt;/strong&gt; where all dots are of the same size and spacing.&lt;/p&gt;

&lt;p&gt;However, achieving a true halftone effect—where dot sizes vary to simulate a gradient or an image’s tonal values—presents a greater challenge with pure &lt;strong&gt;dotted CSS&lt;/strong&gt;. While CSS has powerful gradient and masking capabilities, dynamically varying the size of individual dots in a grid based on an underlying intensity map (as true halftone requires) pushes the boundaries of what’s easily manageable with CSS alone. The complexity arises in making each “dot” in the &lt;strong&gt;background dots CSS&lt;/strong&gt; individually responsive to a larger gradient or image pattern.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let’s Break It Down: Step by Step
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1: The Radial Gradient – A Single Soft Dot
&lt;/h3&gt;

&lt;p&gt;First, we define a &lt;code&gt;&amp;lt;radialGradient&amp;gt;&lt;/code&gt;. This gradient will form the basis of each individual “dot” in our halftone pattern. It transitions from semi-transparent black (&lt;code&gt;stop-opacity:0.5&lt;/code&gt;) at 5% from the center to fully transparent black (&lt;code&gt;stop-opacity:0&lt;/code&gt;) at the edge (100% radius). This creates a soft-edged, circular spot.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;radialGradient&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"radialBlackToTransparent"&lt;/span&gt; &lt;span class="na"&gt;cx=&lt;/span&gt;&lt;span class="s"&gt;"50%"&lt;/span&gt; &lt;span class="na"&gt;cy=&lt;/span&gt;&lt;span class="s"&gt;"50%"&lt;/span&gt; &lt;span class="na"&gt;r=&lt;/span&gt;&lt;span class="s"&gt;"50%"&lt;/span&gt; &lt;span class="na"&gt;fx=&lt;/span&gt;&lt;span class="s"&gt;"50%"&lt;/span&gt; &lt;span class="na"&gt;fy=&lt;/span&gt;&lt;span class="s"&gt;"50%"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;stop&lt;/span&gt; &lt;span class="na"&gt;offset=&lt;/span&gt;&lt;span class="s"&gt;"5%"&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"stop-color:black; stop-opacity:0.5"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;stop&lt;/span&gt; &lt;span class="na"&gt;offset=&lt;/span&gt;&lt;span class="s"&gt;"100%"&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"stop-color:black; stop-opacity:0"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/radialGradient&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Visualizing the Circle Pattern:&lt;/em&gt;&lt;/strong&gt;&lt;br&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%2Fzt5lakl9gyjzkmrfsqbi.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzt5lakl9gyjzkmrfsqbi.png" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 2: The Circle Pattern – A Grid of Soft Dots
&lt;/h3&gt;

&lt;p&gt;Next, we use a  element to repeat our radial gradient in a grid. The pattern tile is 20×20 units (width="20" height="20"). Inside this tile, we place a circle of radius 10 (r="10") at the center (cx="10" cy="10"), filling it with the radial gradient we just defined (&lt;code&gt;fill="url(#radialBlackToTransparent)"&lt;/code&gt;). &lt;code&gt;patternUnits="userSpaceOnUse"&lt;/code&gt; means the width and height are absolute coordinate values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;pattern&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"circlesPattern"&lt;/span&gt; &lt;span class="na"&gt;x=&lt;/span&gt;&lt;span class="s"&gt;"0"&lt;/span&gt; &lt;span class="na"&gt;y=&lt;/span&gt;&lt;span class="s"&gt;"0"&lt;/span&gt; &lt;span class="na"&gt;width=&lt;/span&gt;&lt;span class="s"&gt;"20"&lt;/span&gt; &lt;span class="na"&gt;height=&lt;/span&gt;&lt;span class="s"&gt;"20"&lt;/span&gt; &lt;span class="na"&gt;patternUnits=&lt;/span&gt;&lt;span class="s"&gt;"userSpaceOnUse"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;circle&lt;/span&gt; &lt;span class="na"&gt;cx=&lt;/span&gt;&lt;span class="s"&gt;"10"&lt;/span&gt; &lt;span class="na"&gt;cy=&lt;/span&gt;&lt;span class="s"&gt;"10"&lt;/span&gt; &lt;span class="na"&gt;r=&lt;/span&gt;&lt;span class="s"&gt;"10"&lt;/span&gt; &lt;span class="na"&gt;fill=&lt;/span&gt;&lt;span class="s"&gt;"url(#radialBlackToTransparent)"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/pattern&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Visualizing the CSS Dotted Background Circle Pattern&lt;/em&gt;&lt;/strong&gt;&lt;br&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%2F60l9n2j3dywvwtrg8nmm.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F60l9n2j3dywvwtrg8nmm.png" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 3: The Linear Gradient – The Intensity Mask
&lt;/h3&gt;

&lt;p&gt;Now, we define a &lt;code&gt;&amp;lt;linearGradient&amp;gt;&lt;/code&gt;. This gradient will control the overall intensity or density of the halftone dots across the image. It transitions vertically (&lt;code&gt;x1="0%" y1="0%" x2="0%" y2="100%"&lt;/code&gt;) from semi-transparent black (&lt;code&gt;stop-opacity:0.5&lt;/code&gt;) at the top to fully transparent black (&lt;code&gt;stop-opacity:0&lt;/code&gt;) at the bottom. This gradient will later be multiplied with our dot pattern. Where this gradient is darker, the dots will appear more prominent.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="ni"&gt;&amp;amp;lt;&lt;/span&gt;linearGradient id="linearBlackToTransparent" x1="0%" y1="0%" x2="0%" y2="100%"&lt;span class="ni"&gt;&amp;amp;gt;&lt;/span&gt;
  &lt;span class="ni"&gt;&amp;amp;lt;&lt;/span&gt;stop offset="0%" style="stop-color:black; stop-opacity:0.5" /&lt;span class="ni"&gt;&amp;amp;gt;&lt;/span&gt;
  &lt;span class="ni"&gt;&amp;amp;lt;&lt;/span&gt;stop offset="100%" style="stop-color:black; stop-opacity:0" /&lt;span class="ni"&gt;&amp;amp;gt;&lt;/span&gt;
&lt;span class="ni"&gt;&amp;amp;lt;&lt;/span&gt;/linearGradient&lt;span class="ni"&gt;&amp;amp;gt;&lt;/span&gt;```



&lt;span class="nt"&gt;&amp;lt;h4&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"text-align: center;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Visualizing the Linear Gradient:&lt;span class="nt"&gt;&amp;lt;/h4&amp;gt;&amp;lt;p&amp;gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;loading=&lt;/span&gt;&lt;span class="s"&gt;"lazy"&lt;/span&gt; &lt;span class="na"&gt;decoding=&lt;/span&gt;&lt;span class="s"&gt;"async"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"aligncenter size-full wp-image-4762"&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://www.coding-dude.com/wp/wp-content/uploads/2025/05/css-linear-gradient-pattern.png"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"css linear gradient pattern"&lt;/span&gt; &lt;span class="na"&gt;width=&lt;/span&gt;&lt;span class="s"&gt;"471"&lt;/span&gt; &lt;span class="na"&gt;height=&lt;/span&gt;&lt;span class="s"&gt;"441"&lt;/span&gt; &lt;span class="na"&gt;srcset=&lt;/span&gt;&lt;span class="s"&gt;"https://www.coding-dude.com/wp/wp-content/uploads/2025/05/css-linear-gradient-pattern.png 471w, https://www.coding-dude.com/wp/wp-content/uploads/2025/05/css-linear-gradient-pattern-300x281.png 300w"&lt;/span&gt; &lt;span class="na"&gt;sizes=&lt;/span&gt;&lt;span class="s"&gt;"(max-width: 471px) 100vw, 471px"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"9db0862b9cf2e44f8d962262c5a80491"&lt;/span&gt; &lt;span class="na"&gt;data-index=&lt;/span&gt;&lt;span class="s"&gt;"2"&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"float: none; margin:10px 0 10px 0; text-align:center;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;&amp;lt;script&lt;/span&gt; &lt;span class="na"&gt;async=&lt;/span&gt;&lt;span class="s"&gt;""&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt; 
&lt;span class="nt"&gt;&amp;lt;ins&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"adsbygoogle"&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"display:block"&lt;/span&gt; &lt;span class="na"&gt;data-ad-client=&lt;/span&gt;&lt;span class="s"&gt;"ca-pub-3421619882899259"&lt;/span&gt; &lt;span class="na"&gt;data-ad-slot=&lt;/span&gt;&lt;span class="s"&gt;"9789071689"&lt;/span&gt; &lt;span class="na"&gt;data-ad-format=&lt;/span&gt;&lt;span class="s"&gt;"auto"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/ins&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;(adsbygoogle=window.adsbygoogle||[]).push({});&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&amp;lt;h3&amp;gt;&lt;/span&gt;Step 4: Blending the Pattern and Linear Gradient&lt;span class="nt"&gt;&amp;lt;/h3&amp;gt;&amp;lt;p&amp;gt;&lt;/span&gt;This is where SVG filters (&lt;span class="nt"&gt;&amp;lt;code&amp;gt;&lt;/span&gt;&lt;span class="ni"&gt;&amp;amp;lt;&lt;/span&gt;filter&lt;span class="ni"&gt;&amp;amp;gt;&lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;/code&amp;gt;&lt;/span&gt;) come into play. We need to combine our dot pattern and the linear gradient. Filters operate on image data. So, first, we need to “render” our pattern and linear gradient into image sources that the filter can use. We do this by creating hidden&lt;span class="ni"&gt;&amp;amp;nbsp;&lt;/span&gt; elements filled with them:&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;



```xml

&lt;span class="ni"&gt;&amp;amp;lt;&lt;/span&gt;rect id="circlesSourceLayer" width="100%" height="100%" fill="url(#circlesPattern)" /&lt;span class="ni"&gt;&amp;amp;gt;&lt;/span&gt;
&lt;span class="ni"&gt;&amp;amp;lt;&lt;/span&gt;rect id="overlaySourceLayer" width="100%" height="100%" fill="url(#linearBlackToTransparent)" /&lt;span class="ni"&gt;&amp;amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inside the &lt;code&gt;&amp;lt;filter&amp;gt;&lt;/code&gt;:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;feImage xlink:href="#circlesSourceLayer" result="circlesInput" ... /&amp;gt;&lt;/code&gt;: Loads the rendered circles pattern as an image input named “circlesInput”.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;feImage xlink:href="#overlaySourceLayer" result="overlayInput" ... /&amp;gt;&lt;/code&gt;: Loads the rendered linear gradient as an image input named “overlayInput”.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;feBlend mode="multiply" in="circlesInput" in2="overlayInput" result="multiplied" /&amp;gt;&lt;/code&gt;: This is the key step. It takes “circlesInput” and “overlayInput” and blends them using the &lt;code&gt;multiply&lt;/code&gt; mode.&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;multiply&lt;/code&gt; blend mode multiplies the color channel values of the two inputs.&lt;/li&gt;
&lt;li&gt;Since both our inputs are shades of black (grayscale) and transparent, multiplying them will result in darker areas where both inputs are dark/opaque, and lighter/transparent areas where either input is light/transparent.&lt;/li&gt;
&lt;li&gt;Effectively, the linear gradient modulates the opacity of the dots. Dots will be more opaque (and thus appear stronger) where the linear gradient is darker (top), and fainter where the linear gradient is transparent (bottom).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;



```xml
&amp;lt;filter id="blendAndThresholdFilter_Step4" x="0" y="0" width="100%" height="100%" filterUnits="userSpaceOnUse"&amp;gt;
  &amp;lt;feImage xlink:href="#circlesSourceLayer" result="circlesInput" x="0" y="0" width="100%" height="100%"/&amp;gt;
  &amp;lt;feImage xlink:href="#overlaySourceLayer" result="overlayInput" x="0" y="0" width="100%" height="100%"/&amp;gt;
  &amp;lt;feBlend mode="multiply" in="circlesInput" in2="overlayInput" result="multiplied" /&amp;gt;
&amp;lt;/filter&amp;gt;
```



&lt;h4&gt;Visualizing the Multiply Blend:&lt;/h4&gt;
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.coding-dude.com%2Fwp%2Fwp-content%2Fuploads%2F2025%2F05%2Fcss-multiply-blend-dotted-background.png" alt="css multiply blend dotted background" width="469" height="472"&gt;(This shows the result of the multiply blend. Notice how the dots are stronger at the top.)&lt;h3&gt;Step 5: The Threshold – Creating Hard Dots&lt;/h3&gt;
&lt;p&gt;The blended image from Step 4 still has soft, semi-transparent dots. To get the classic halftone look, we need to convert these soft dots into hard-edged, fully opaque (or fully transparent) dots. This is done using a threshold operation. We use &lt;code&gt;&lt;/code&gt;to achieve this. The matrix provided:&lt;/p&gt;


&lt;pre class="highlight xml"&gt;&lt;code&gt;values="
  1 0 0 0 0
  0 1 0 0 0
  0 0 1 0 0
  0 0 0 255 -128"
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;This matrix operates on the RGBA (Red, Green, Blue, Alpha) channels of each pixel from the “multiplied” result. Let’s look at the rows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;R’ = 1*R + 0*G + 0*B + 0*A + 0 (Red channel remains unchanged)&lt;/li&gt;
&lt;li&gt;G’ = 0*R + 1*G + 0*B + 0*A + 0 (Green channel remains unchanged)&lt;/li&gt;
&lt;li&gt;B’ = 0*R + 0*G + 1*B + 0*A + 0 (Blue channel remains unchanged)&lt;/li&gt;
&lt;li&gt;A’ = 0*R + 0*G + 0*B + 255*A – 128 (Alpha channel is transformed)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The critical part is the alpha channel transformation: &lt;code&gt;A_new = 255 * A_old - 128&lt;/code&gt;. (Note: A_old is typically normalized 0-1, so it’s actually more like `A_new_normalized = (255 * A_old_normalized – 128) / 255`). What this effectively does:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If a pixel’s original alpha (A_old) value (from the “multiplied” image) is greater than 0.5 (or 128 when scaled to 0-255 range), then &lt;code&gt;255*A_old - 128&lt;/code&gt; will be a positive value, resulting in an opaque pixel (A_new will be clamped to 1, or 255).&lt;/li&gt;
&lt;li&gt;If a pixel’s original alpha is less than or equal to 0.5, then &lt;code&gt;255*A_old - 128&lt;/code&gt; will be zero or negative, resulting in a transparent pixel (A_new will be clamped to 0).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So, any pixel with an opacity greater than 50% becomes fully opaque black (since R,G,B were black), and any pixel with opacity 50% or less becomes fully transparent. This creates the hard-edged dots characteristic of halftone.&lt;/p&gt;


&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="ni"&gt;&amp;amp;lt;&lt;/span&gt;feColorMatrix type="matrix"
  values="
    1 0 0 0 0
    0 1 0 0 0
    0 0 1 0 0
    0 0 0 255 -128" 
  result="thresholded" /&lt;span class="ni"&gt;&amp;amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;The visual for this step is essentially the final result, as it’s the last operation in the filter chain.&lt;/p&gt;
&lt;p&gt;For these more sophisticated halftone effects, developers often look beyond basic CSS or combine it with other technologies like SVG, as we’ve explored.&lt;/p&gt;
&lt;p&gt;If you’re looking for ready-made solutions or tools to help, a &lt;a href="https://www.mockofun.com/template/halftone-generator/" rel="noopener noreferrer"&gt;halftone generator&lt;/a&gt; can be an excellent resource for quickly creating custom patterns.&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%2Fwww.coding-dude.com%2Fwp%2Fwp-content%2Fuploads%2F2025%2F05%2Fhalftone-images.jpg" 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%2Fwww.coding-dude.com%2Fwp%2Fwp-content%2Fuploads%2F2025%2F05%2Fhalftone-images.jpg" alt="halftone images" width="1200" height="642"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Understanding the principles behind a &lt;a href="https://www.psd-dude.com/tutorials/halftone-gradient.aspx" rel="noopener noreferrer"&gt;halftone gradient&lt;/a&gt; is also crucial for a deeper appreciation of the effect, and for high-quality, scalable results, exploring &lt;a href="https://www.psd-dude.com/tutorials/resources/vector-halftone.aspx" rel="noopener noreferrer"&gt;vector halftone&lt;/a&gt; techniques is highly recommended.&lt;/p&gt;
&lt;p&gt;These resources can complement your CSS efforts, especially when aiming for dynamic and detailed halftone dotted backgrounds. Alternatively, there are high quality premade &lt;a href="https://www.photoshopsupply.com/patterns-textures/halftone-texture" rel="noopener noreferrer"&gt;halftone pattern Photoshop&lt;/a&gt; addons that you can download for free online.&lt;/p&gt;
&lt;h2&gt;Putting It All Together: The Filter Chain Diagram&lt;/h2&gt;
&lt;p&gt;Here’s a diagram showing how these elements combine within the SVG filter to create the CSS dotted background halftone effect:&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%2Fwww.coding-dude.com%2Fwp%2Fwp-content%2Fuploads%2F2025%2F05%2Fhalftone-dotted-background-css.jpg" 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%2Fwww.coding-dude.com%2Fwp%2Fwp-content%2Fuploads%2F2025%2F05%2Fhalftone-dotted-background-css.jpg" alt="halftone dotted background CSS" width="1200" height="800"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;filterUnits="userSpaceOnUse"&lt;/code&gt; attribute on the &lt;code&gt;&lt;/code&gt;element means that all coordinates and lengths within the filter are interpreted in the current user coordinate system (the coordinate system of the element the filter is applied to). The &lt;code&gt;x="0" y="0" width="100%" height="100%"&lt;/code&gt; on the &lt;code&gt;&lt;/code&gt;and &lt;code&gt;&lt;/code&gt;elements define the region to which the filter effect applies and from which the images are sourced, relative to the target element’s bounding box.&lt;/p&gt;
&lt;p&gt;If you take a close look at how the SVG filter is composed, you will notice that you can change the halftone dotted background effect by changing the linear gradient. Change the direction, add different stops or even switch to a radial gradient and you will get different halftone effects.&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%2Fwww.coding-dude.com%2Fwp%2Fwp-content%2Fuploads%2F2025%2F05%2Fbackground-dots-css.jpg" 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%2Fwww.coding-dude.com%2Fwp%2Fwp-content%2Fuploads%2F2025%2F05%2Fbackground-dots-css.jpg" alt="background dots css" width="1200" height="533"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;The Final Result&lt;/h2&gt;
&lt;p&gt;The defined SVG &lt;code&gt;&amp;lt;filter&amp;gt;&lt;/code&gt; with &lt;code&gt;id="blendAndThresholdFilter"&lt;/code&gt; can then be applied to any HTML element using the CSS &lt;code&gt;filter&lt;/code&gt; property. For example, &lt;code&gt;&amp;lt;div style="filter:url(#blendAndThresholdFilter);"&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt;. The content of the div will be replaced by the output of the SVG filter.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;In the provided code snippet at the top of the tutorial, the main &lt;code&gt;&amp;lt;svg id="halftonePattern" ...&amp;gt;&lt;/code&gt; element is hidden. It only serves as a container for the &lt;code&gt;&amp;lt;defs&amp;gt;&lt;/code&gt;. The actual effect is shown by applying the filter to the &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; below it:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&amp;lt;div style="width:100vw;height:100vh;filter:url(#blendAndThresholdFilter)"&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt;&lt;/p&gt;


&lt;/blockquote&gt;

&lt;h4&gt;Live Demo of the Final Effect:&lt;/h4&gt;

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

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>css</category>
    </item>
    <item>
      <title>SVG Animation Example</title>
      <dc:creator>codingdudecom</dc:creator>
      <pubDate>Sun, 27 Apr 2025 07:35:03 +0000</pubDate>
      <link>https://dev.to/codingdudecom/svg-animation-example-kcf</link>
      <guid>https://dev.to/codingdudecom/svg-animation-example-kcf</guid>
      <description>&lt;p&gt;READ ORIGINAL POST: &lt;a href="https://www.coding-dude.com/wp/css/animate-svg/" rel="noopener noreferrer"&gt;How to Animate SVG with CSS &amp;amp; JS&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  SVG Typography Animation
&lt;/h2&gt;

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

&lt;p&gt;Let's bring your SVG images to life. In this tutorial, I'll show you how to animate them using CSS and JavaScript. We'll cover the basics of CSS animations, animating SVG elements, and even triggering them with scrolling or a simple click. Check out the demo above to see it in action - you can trigger the animation by scrolling, clicking, or hitting play for a continuous loop.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create an SVG Image for the Animation
&lt;/h2&gt;

&lt;p&gt;To get started with SVG animation, we need an SVG image. You can create one using &lt;a href="https://inkscape.org/" rel="noopener noreferrer"&gt;Inkscape&lt;/a&gt;, &lt;a href="https://www.adobe.com/products/illustrator.html" rel="noopener noreferrer"&gt;Adobe Illustrator&lt;/a&gt;, or &lt;a href="https://www.psd-dude.com/tutorials/resources/adobe-photoshop-twenty-five-years-anniversary-infographic.aspx" rel="noopener noreferrer"&gt;latest Photoshop versions&lt;/a&gt;. Here are your options:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Draw a vector image from scratch&lt;/li&gt;
&lt;li&gt;Convert a photo or image to SVG (check out this tutorial on &lt;a href="https://www.psd-dude.com/tutorials/image-to-vector-in-photoshop.aspx" rel="noopener noreferrer"&gt;how to convert an image to vector using Photoshop&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Use a vector image generator&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We'll use the free online &lt;a href="https://www.mockofun.com/template/text-in-shape/" rel="noopener noreferrer"&gt;text in shape generator&lt;/a&gt; from MockoFun. It's easy to create a cool typography SVG design. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.mockofun.com/template/text-in-shape/" rel="noopener noreferrer"&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%2Fbx3z3b6oc3qsbup502uf.webp" alt="text in shape"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.coding-dude.com/wp/wp-content/uploads/2025/04/text-in-shape-3.svg" class="crayons-btn crayons-btn--primary" rel="noopener noreferrer"&gt;Download the SVG version&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.mockofun.com/template/text-in-shape/" rel="noopener noreferrer"&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%2Ffh8tukjl1s4z2ys0889r.webp"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.coding-dude.com/wp/wp-content/uploads/2025/04/text-in-shape-2.svg" class="crayons-btn crayons-btn--primary" rel="noopener noreferrer"&gt;Download the SVG version&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.mockofun.com/template/text-in-shape/" rel="noopener noreferrer"&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%2Frbvw9dd8z02065fznd07.webp"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.coding-dude.com/wp/wp-content/uploads/2025/04/text-in-shape-2.svg" class="crayons-btn crayons-btn--primary" rel="noopener noreferrer"&gt;Download the SVG version&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;We've got our SVG image, so let's move on to animating it!&lt;/p&gt;

&lt;h2&gt;
  
  
  Animating SVG with CSS
&lt;/h2&gt;

&lt;p&gt;To animate an SVG with CSS, you need to use it as an inline SVG in your HTML page. This means copying the SVG definition from a text editor and pasting it into your HTML.&lt;/p&gt;

&lt;p&gt;When you open the SVG, you'll see groups (&lt;code&gt;&amp;lt;g/&amp;gt;&lt;/code&gt; tags) and paths (&lt;code&gt;&amp;lt;path/&amp;gt;&lt;/code&gt; tags). We'll focus on the paths, as that's what we'll animate.&lt;/p&gt;

&lt;p&gt;CSS for SVG works similarly to HTML, but with different properties. Check out this intro to &lt;a href="https://www.psd-dude.com/tutorials/resources/adobe-photoshop-twenty-five-years-anniversary-infographic.aspx" rel="noopener noreferrer"&gt;CSS for SVG&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  SVG Color Animation
&lt;/h2&gt;

&lt;p&gt;We'll animate the colors of the two &lt;code&gt;&amp;lt;path/&amp;gt;&lt;/code&gt; elements in our SVG: the background shape and the text inside the shape. We'll use CSS &lt;code&gt;hsl()&lt;/code&gt; values, which make it easy to work with colors.&lt;/p&gt;

&lt;p&gt;To change the colors, we'll only modify the hue, keeping the saturation and lightness the same. This will create a harmonious color scheme.&lt;/p&gt;

&lt;p&gt;Here's the code:&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;SATURATION&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;100%&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;LIGHTNESS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;50%&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;currentHue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newHue&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;360&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;360&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;360&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;shapeHue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;180&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;currentHue&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="mi"&gt;360&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;dynamicColor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`hsl(&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;currentHue&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="nx"&gt;SATURATION&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="nx"&gt;LIGHTNESS&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;shapeColor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`hsl(&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;shapeHue&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="nx"&gt;SATURATION&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="nx"&gt;LIGHTNESS&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;)`&lt;/span&gt;

&lt;span class="nx"&gt;svgTexts&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;el&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fill&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;dynamicColor&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="nx"&gt;svgShapes&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;el&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fill&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;shapeColor&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;
  
  
  Triggering the Animation
&lt;/h2&gt;

&lt;p&gt;We'll use three ways to trigger the animation:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;PLAY/PAUSE button&lt;/strong&gt;: Starts or pauses the color cycle.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mouse hold&lt;/strong&gt;: Changes the color while the mouse button is held down.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mouse scroll wheel&lt;/strong&gt;: Changes the color when scrolling.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's break it down:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;PLAY/PAUSE button&lt;/strong&gt;: Uses a timer to trigger a color change every 100ms.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;playPauseCheckbox&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;change&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;event&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;// ...&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Mouse hold&lt;/strong&gt;: Uses &lt;code&gt;setInterval()&lt;/code&gt; to change the color while the mouse button is held down.
&lt;/li&gt;
&lt;/ul&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;handleMouseDown&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;handleMouseUp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Mouse scroll wheel&lt;/strong&gt;: Changes the color when scrolling. We'll increment the hue by 15° each time we scroll down or decrease the hue when scrolling up.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;wheel&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;handleWheel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;passive&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;handleWheel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it! You now know how to create a SVG text in shape design and animate it with CSS and JS.&lt;/p&gt;

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

&lt;p&gt;So there it is: you now know how to create a SVG text in shape design and use CSS and JS to animate it. This is a pretty cool web design trick that you can easily integrate in your website. Drop me a comment if you have any questions.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Coding Tattoos</title>
      <dc:creator>codingdudecom</dc:creator>
      <pubDate>Sat, 16 Nov 2024 11:27:24 +0000</pubDate>
      <link>https://dev.to/codingdudecom/coding-tattoos-3l16</link>
      <guid>https://dev.to/codingdudecom/coding-tattoos-3l16</guid>
      <description>&lt;p&gt;As a programmer, I see tattoos as a way to express my passion for code. They're more than just art—they tell a story about who I am and what I love. &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%2Fyjm1kl8gcmwnr06bbkww.jpg" 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%2Fyjm1kl8gcmwnr06bbkww.jpg" alt="Coding Tattoo" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you're like me, you've probably thought about getting a tattoo but weren't sure what design to choose. In this article, I'll share what I've learned about tattoo culture among developers and help you find inspiration for your own ink. Let's explore how coding tattoos can combine creativity and meaning to show off your love for programming. &lt;/p&gt;

&lt;p&gt;As a hardcore programmer, I think &lt;strong&gt;&lt;em&gt;the ultimate tattoo design for programmers&lt;/em&gt;&lt;/strong&gt; would be a tattoo design made with AI. At the end of this article I will tell you about a free &lt;a href="https://www.mockofun.com/ai-tattoo-generator/" rel="noopener noreferrer"&gt;AI tattoo generator&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Developers Love Coding Tattoos
&lt;/h2&gt;

&lt;p&gt;Developers use tattoos to express their passion for coding. Tattoos show their creativity, dedication, and connection to programming culture. Coding tattoos combine technical elements with artistic designs. These tattoos help developers display their skills and identity.&lt;/p&gt;

&lt;p&gt;Coding tattoos also reflect the growing influence of technology in everyday life. Developers pick designs that symbolize their love for problem-solving and innovation. Tattoos for programmers often carry deep personal meaning.&lt;/p&gt;

&lt;h2&gt;
  
  
  Coding Tattoo Ideas
&lt;/h2&gt;

&lt;p&gt;Many developers choose tech-inspired body art to celebrate their work and interests. Coding tattoos offer a unique way to blend personal expression with professional pride.&lt;/p&gt;

&lt;p&gt;Binary code tattoos and syntax elements like curly braces, semicolons, or HTML tags show their connection to the fundamentals of programming. Some coders prefer algorithm tattoos, such as Fibonacci sequences or graph structures, which combine logic and beauty. Others honor their favorite programming languages with designs like Python logos, Ruby gems, or JavaScript symbols. These tattoos let developers express their love for tech and showcase the tools and ideas that define their work.&lt;/p&gt;

&lt;p&gt;Let's see some ideas:&lt;/p&gt;

&lt;h3&gt;
  
  
  "Hello, World!"
&lt;/h3&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%2Fddxuxg7wf7u3rpuwjri5.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fddxuxg7wf7u3rpuwjri5.png" alt="Hello World! Coding Tattoo" width="800" height="1169"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A simple yet iconic representation of a programmer's first step in coding.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;"Hello, World!"&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  Binary Code
&lt;/h3&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%2Fg49gp9m2lq5c1t6q6r2q.jpg" 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%2Fg49gp9m2lq5c1t6q6r2q.jpg" alt="Binary Code Tattoo" width="736" height="757"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A short phrase or word in binary, such as "Code" (e.g., 01000011 01101111 01100100 01100101).&lt;/li&gt;
&lt;li&gt;The binary could be arranged in a line or shaped into a meaningful symbol like a heart or infinity loop.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Code Brackets
&lt;/h3&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%2Fgvkr7mvbmr5ds11zmovt.jpg" 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%2Fgvkr7mvbmr5ds11zmovt.jpg" alt="Code brackets tattoo" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Minimalist brackets, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;{ }&lt;/code&gt; (curly brackets for code blocks).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt; /&amp;gt;&lt;/code&gt; (HTML tags).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;[ ]&lt;/code&gt; (array brackets).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  "if (true)" Statement
&lt;/h3&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%2Fjvxa52unqmy2uyz3eju1.jpg" 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%2Fjvxa52unqmy2uyz3eju1.jpg" alt="Coding tattoo if-then-else" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Playfully include an unfinished condition, like:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;if (true) {  &lt;br&gt;
  // keep coding;  &lt;br&gt;
}&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;A symbolic reminder to stay passionate about programming.&lt;/p&gt;

&lt;h3&gt;
  
  
  Semicolon &lt;code&gt;;&lt;/code&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A simple semicolon representing the end of a statement in many programming languages.&lt;/li&gt;
&lt;li&gt;It can also symbolize perseverance, often associated with the "semicolon movement."&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  "while ( ! (success ) ) ;"
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A witty infinite loop symbolizing persistence and the journey to achieve success.
Example:
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;while ( !(success) ) ;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can style it with minimalist font or wrap it around your wrist or arm.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  404 Error
&lt;/h3&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%2F4ilj6cukwgxvdzar1n06.jpg" 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%2F4ilj6cukwgxvdzar1n06.jpg" alt="404 Not Found Error Tattoo" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A humorous nod to the infamous error message:
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;404: Not Found&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can place it subtly to suggest a "missing" feature, like on your ankle or wrist.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Null Pointer
&lt;/h3&gt;

&lt;p&gt;A classic representation of uninitialized memory in programming:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;NULL&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Combine with a pointer symbol (-&amp;gt;) for an extra nerdy twist.&lt;/p&gt;

&lt;h3&gt;
  
  
  Boolean Logic
&lt;/h3&gt;

&lt;p&gt;A simple, clean design of true or false in plain text, or a combination like:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;true &amp;amp;&amp;amp; !false&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Symbolic of truth and clarity.&lt;/p&gt;

&lt;h3&gt;
  
  
  Regex Pattern
&lt;/h3&gt;

&lt;p&gt;A small, meaningful regex expression, such as:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;/^code$/&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;This matches "code" exactly and looks sleek in a monospaced font.&lt;/p&gt;

&lt;h3&gt;
  
  
  Lambda Symbol
&lt;/h3&gt;

&lt;p&gt;A nod to functional programming:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;λ x . x + 1&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;This minimalist mathematical function form is perfect for anyone into functional programming or lambda calculus.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use Online Tools to Create AI Tattoo Designs
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.mockofun.com/ai-tattoo-generator/" rel="noopener noreferrer"&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%2F0in0713kimfu4xf6vqr3.png" alt="Best AI Tattoo Generator" width="800" height="491"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can use online tools to create unique tattoo designs with ease. The &lt;a href="https://www.mockofun.com/ai-tattoo-generator/" rel="noopener noreferrer"&gt;AI tattoo generator&lt;/a&gt; helps you turn text descriptions into stunning tattoo designs. This tool stands out as the best AI tattoo generator because it is online, free, and easy to use. You can describe your idea in words, and the generator will transform it into a design that matches your vision. Whether you want a minimalist code tattoo or an intricate tech-inspired pattern, this tool makes designing fast and fun for programmers.&lt;/p&gt;

&lt;p&gt;Here's an example:&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%2Fi5qonrvbh2olzwmicnmr.jpg" 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%2Fi5qonrvbh2olzwmicnmr.jpg" alt="Coding Tattoos" width="800" height="369"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Try this &lt;strong&gt;AI Tattoo Prompt&lt;/strong&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;pixel-art simple small tattoo design icon with a programmer working on a computer, 2D flat illustration, black outlines . low-res, blocky, pixel art style, 8-bit graphics &amp;lt;&amp;gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Coding tattoos let you celebrate your love for programming in a creative way. From binary code and syntax symbols to algorithms and AI-inspired designs, the possibilities are endless. &lt;/p&gt;

&lt;p&gt;Whether you already have a tattoo or are planning your first one, remember to choose a design that feels meaningful to you. Your tattoo is a permanent story—make it one that inspires you every day.&lt;/p&gt;

</description>
      <category>tattoo</category>
      <category>webdev</category>
      <category>culture</category>
      <category>programmers</category>
    </item>
    <item>
      <title>Scrolling Text Using HTML</title>
      <dc:creator>codingdudecom</dc:creator>
      <pubDate>Thu, 12 Sep 2024 17:05:28 +0000</pubDate>
      <link>https://dev.to/codingdudecom/scrolling-text-using-html-4o7</link>
      <guid>https://dev.to/codingdudecom/scrolling-text-using-html-4o7</guid>
      <description>&lt;p&gt;When you’ve been building web applications for over 25 years like I have, using HTML, CSS, and JavaScript becomes second nature. In this article, I’ll show you some simple ways to create scrolling text using these tools.&lt;/p&gt;

&lt;p&gt;The post &lt;a href="https://www.coding-dude.com/wp/css/scrolling-text-using-html/" rel="noopener noreferrer"&gt;Scrolling Text Using HTML&lt;/a&gt; appeared first on &lt;a href="https://www.coding-dude.com/" rel="noopener noreferrer"&gt;Coding Dude&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I’ll show you 5 different methods for coding scrolling text with plain HTML, HTML &amp;amp; CSS and finally HTML + CSS + JS.&lt;/p&gt;

&lt;h1&gt;
  
  
  1. Plain HTML Scrolling Text
&lt;/h1&gt;

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

&lt;p&gt;Simply add a  tag around the text to create a scrolling effect. This tag offers a few interesting parameters among which:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;direction&lt;/em&gt; — can be: left, right, up, or down&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;scrollamount&lt;/em&gt; - the speed of the scroll text&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;loop&lt;/em&gt; — how many times should the scrolling repeat&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;NOTE:&lt;/em&gt;&lt;/strong&gt; The  is a deprecated HTML tag, so I’d recommend restrain in using it for modern web projects.&lt;/p&gt;

&lt;h1&gt;
  
  
  2. Animated Scrolling Text with CSS
&lt;/h1&gt;

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

&lt;p&gt;Define a CSS animation called scroll that animates the &lt;code&gt;translateX&lt;/code&gt; property.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;

&lt;span class="k"&gt;@keyframes&lt;/span&gt; &lt;span class="nb"&gt;scroll&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translateX&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="p"&gt;}&lt;/span&gt;
 &lt;span class="err"&gt;100&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translateX&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="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;Then apply that animation to your text element:&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;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"scrolling-text"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Scrolling Text&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;by adding this CSS:&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;.scrolling-text&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;overflow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;hidden&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nl"&gt;white-space&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;nowrap&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nl"&gt;box-sizing&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;animation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;scroll&lt;/span&gt; &lt;span class="m"&gt;10s&lt;/span&gt; &lt;span class="n"&gt;linear&lt;/span&gt; &lt;span class="n"&gt;infinite&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;Changing from &lt;code&gt;translateX&lt;/code&gt; to &lt;code&gt;translateY&lt;/code&gt; will give you a vertical scrolling text. Switching 0% and 100% around will give you the reverse scrolling text direction. And in the &lt;code&gt;.scrolling-text&lt;/code&gt; CSS class if you change the 10s duration of the animation you change the speed of the scrolling text.&lt;/p&gt;

&lt;h1&gt;
  
  
  3. HTML + CSS + JavaScript Scrolling Text
&lt;/h1&gt;

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

&lt;p&gt;HTML code:&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;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"scrolling-text"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
Scrolling Text Scrolling Text Scrolling Text
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;CSS code:&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;.scrolling-text&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;30vw&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nl"&gt;white-space&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;nowrap&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nl"&gt;overflow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;hidden&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nl"&gt;box-sizing&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;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;clamp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;16px&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;50&lt;/span&gt;&lt;span class="n"&gt;dvh&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;220px&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nl"&gt;white-space&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;nowrap&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;0&lt;/span&gt; &lt;span class="nb"&gt;auto&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;JavaScript code:&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;container&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;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.scrolling-text&lt;/span&gt;&lt;span class="dl"&gt;'&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;scrollAmount&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="nf"&gt;setInterval&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="nx"&gt;scrollAmount&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="nx"&gt;container&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;scrollLeft&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;scrollAmount&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;scrollAmount&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="nx"&gt;container&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;scrollWidth&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;scrollAmount&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="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;This is my most “unelegant” solution for making scrolling text. Basically it’s cramming a text in a container with scroll and changes the scrolling of the container programmatically. When the scroll amount goes over the container amount it resets.&lt;/p&gt;

&lt;h1&gt;
  
  
  4. Scroll Text with jQuery
&lt;/h1&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="nf"&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="nf"&gt;ready&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
 &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;loop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.scrolling-text&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;css&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;scrollLeft&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="nf"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.scrolling-text&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;scrollLeft&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;+=1000&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;10000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;linear&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;loop&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;Use the &lt;code&gt;animate()&lt;/code&gt; jQuery function to animate the &lt;code&gt;scrollLeft&lt;/code&gt; property and this will create a scrolling text effect.&lt;/p&gt;

&lt;p&gt;In my view jQuery is a bit of an overkill in this situation, and it only makes sense if you already use jQuery in your project.&lt;/p&gt;

&lt;p&gt;Of course, &lt;code&gt;animate()&lt;/code&gt; can also be used for animating the &lt;code&gt;translateX&lt;/code&gt; or &lt;code&gt;translateY&lt;/code&gt; properties as seen above.&lt;/p&gt;

&lt;h1&gt;
  
  
  5. Scrolling Text with Canvas HTML5
&lt;/h1&gt;

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

&lt;p&gt;This is my favorite method. Especially because it’s so flexible and offers so many possibilities, like for example exporting the scrolling text as GIF or even video. You can see this in action by going the the &lt;strong&gt;&lt;em&gt;&lt;a href="https://www.psd-dude.com/scrolling-text/" rel="noopener noreferrer"&gt;Scrolling Text&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt; generator on PSDDude where you can create your own customized scrolling text images and videos.&lt;/p&gt;

&lt;p&gt;The HTML code is straight forwards:&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;canvas&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"scrollingCanvas"&lt;/span&gt; &lt;span class="na"&gt;width=&lt;/span&gt;&lt;span class="s"&gt;"300"&lt;/span&gt; &lt;span class="na"&gt;height=&lt;/span&gt;&lt;span class="s"&gt;"50"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/canvas&amp;gt;&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;and the JS is where the magic happens:&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;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;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;scrollingCanvas&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;ctx&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Scrolling Text Example&lt;/span&gt;&lt;span class="dl"&gt;"&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;x&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="nx"&gt;width&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;draw&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="nx"&gt;ctx&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="c1"&gt;// Clear the canvas&lt;/span&gt;
 &lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;font&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;20px Arial&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fillStyle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;black&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fillText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;text&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;30&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="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Adjust speed of scrolling here&lt;/span&gt;
 &lt;span class="k"&gt;if &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;&amp;lt;&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;measureText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;text&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="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="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="c1"&gt;// Reset position when text is out of view&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;draw&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;draw&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;Using a loop with &lt;code&gt;requestAnimationFrame()&lt;/code&gt; calling the function &lt;code&gt;draw()&lt;/code&gt; is actually the way HTML5 games implement their graphics drawing. This is a cool way for creating smooth scrolling text.&lt;/p&gt;

&lt;p&gt;You get the size on screen of the text using the &lt;code&gt;measureText()&lt;/code&gt; context method. This allows creating a seamless scrolling text by resetting the text position when it reaches the end position.&lt;/p&gt;

&lt;h1&gt;
  
  
  Bonus: A Few Scrolling Text Ideas
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://www.psd-dude.com/scrolling-text/#m0uqu9rk" rel="noopener noreferrer"&gt;LED Scrolling Text GIF&lt;/a&gt;:&lt;br&gt;
&lt;a href="https://media.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%2Fj5al4t6jz5wf6jp66j7e.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fj5al4t6jz5wf6jp66j7e.gif" alt="LED Scrolling Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.psd-dude.com/scrolling-text/#m0ur6r1y" rel="noopener noreferrer"&gt;Star Wars Opening Crawl Scrolling Text Generator&lt;/a&gt;:&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/RkRJeGlwCQI"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.psd-dude.com/scrolling-text/#m0sd5fsu" rel="noopener noreferrer"&gt;Stock Market Scrolling Text&lt;/a&gt;:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1100%2Fformat%3Awebp%2F1%2AZ7umTkUdp3ZS5CPk2RQdfA.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1100%2Fformat%3Awebp%2F1%2AZ7umTkUdp3ZS5CPk2RQdfA.gif" alt="Stock Market Scrolling Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.psd-dude.com/scrolling-text/#m0sfzqcm" rel="noopener noreferrer"&gt;Weather Scrolling Text&lt;/a&gt;:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1100%2Fformat%3Awebp%2F1%2A-8WQXpIOxMQNurj4d_u3iQ.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afit%3A1100%2Fformat%3Awebp%2F1%2A-8WQXpIOxMQNurj4d_u3iQ.gif" alt="Weather Scrolling Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These were created with the &lt;a href="https://www.psd-dude.com/scrolling-text/" rel="noopener noreferrer"&gt;scrolling text gif and video generator&lt;/a&gt; on &lt;a href="https://www.psd-dude.com/" rel="noopener noreferrer"&gt;PSDDude&lt;/a&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  In Conclusion
&lt;/h1&gt;

&lt;p&gt;Now you know how to make scrolling text using HTML, CSS and/or JavaScript.&lt;/p&gt;

&lt;p&gt;What will you use this for?&lt;/p&gt;

&lt;p&gt;Drop me a comment to let me know. Also, if you feel I’ve missed an important method for creating scrolling text, give me your thoughts on that.&lt;/p&gt;

</description>
      <category>css</category>
      <category>html</category>
      <category>canvas</category>
    </item>
    <item>
      <title>AI Character Generator</title>
      <dc:creator>codingdudecom</dc:creator>
      <pubDate>Wed, 10 Apr 2024 05:45:49 +0000</pubDate>
      <link>https://dev.to/codingdudecom/ai-character-generator-4kgb</link>
      <guid>https://dev.to/codingdudecom/ai-character-generator-4kgb</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/devteam/join-us-for-the-cloudflare-ai-challenge-3000-in-prizes-5f99"&gt;Cloudflare AI Challenge&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;I've build a RPG character AI generator. It generates a name, back story, description of powers and traits plus the image of the character that is consistent with the description.&lt;/p&gt;

&lt;p&gt;The only input necessary is the the class of the character or its species.&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;Demo: &lt;a href="https://www.nickname-generator.net/blog/fantasy-character-names/" rel="noopener noreferrer"&gt;RPG Character Generator&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.nickname-generator.net/blog/fantasy-character-names/" rel="noopener noreferrer"&gt;&lt;img src="https://media.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%2Fvdwham273e7cj07jz9co.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  My Code
&lt;/h2&gt;

&lt;p&gt;You can check out the code here: &lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/codingdudecom" rel="noopener noreferrer"&gt;
        codingdudecom
      &lt;/a&gt; / &lt;a href="https://github.com/codingdudecom/ai-character-generator" rel="noopener noreferrer"&gt;
        ai-character-generator
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Easy-to-use AI character generator that can be integrated in any app. It's based on Cloudflare Workers AI
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;AI Character Generator&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;Easy-to-use AI character generator that can be integrated in any app. It's based on Cloudflare Workers AI.&lt;/p&gt;
&lt;p&gt;The code generates a name, back story, description of powers and traits plus the image of the character that is consistent with the description
The only input necessary is a string that contains a minimal description (eg. the the class of the character or its species).&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Demo&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;Check out a live demo of how this works: &lt;a href="https://www.nickname-generator.net/blog/fantasy-character-names/" rel="nofollow noopener noreferrer"&gt;AI Character Generator&lt;/a&gt;&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;How to install&lt;/h1&gt;

&lt;/div&gt;
&lt;p&gt;First create a Wrangler project for making a Cloudflare Worker. Follow &lt;a href="https://developers.cloudflare.com/workers-ai/get-started/workers-wrangler/" rel="nofollow noopener noreferrer"&gt;this guide&lt;/a&gt;, which in short means:&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;1. Create a NodeJS project from the Cloudflare Workers template:&lt;/h2&gt;

&lt;/div&gt;
&lt;div class="snippet-clipboard-content notranslate position-relative overflow-auto"&gt;&lt;pre class="notranslate"&gt;&lt;code&gt;npm create cloudflare@latest
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Input a name for your project (eg. ai-character-generator) and check &lt;code&gt;Yes&lt;/code&gt; for everthing except for deployment. We will do that later.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;2. Go into the project folder created and find the &lt;code&gt;wrangler.toml&lt;/code&gt; file. You need to activate&lt;/h2&gt;…&lt;/div&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/codingdudecom/ai-character-generator" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  Journey
&lt;/h2&gt;

&lt;p&gt;The app is pretty straight forwards and generates the result in JSON format, so it's very easy to integrate it in any kind of app, website or event game.&lt;/p&gt;

&lt;p&gt;Making the &lt;a href="https://www.nickname-generator.net/blog/fantasy-character-names/" rel="noopener noreferrer"&gt;AI RPG Character Creator&lt;/a&gt; widget I combined web development, AI integration, and Cloudflare Workers for seamless serverless computing. The primary objective was to design an intuitive interface where users could generate unique RPG characters complete with names, backstories, power details, and visual representations.&lt;/p&gt;

&lt;p&gt;One of the standout features of the widget is its ability to generate a cohesive character profile with a name, backstory, powers, and image in real-time. Achieving this level of dynamic content creation using AI was a great experience for me.&lt;/p&gt;

&lt;p&gt;Leveraging Cloudflare Workers allows the widget to handle a large number of concurrent requests without compromising on overall website performance.&lt;/p&gt;

&lt;p&gt;I also learned that using the Dreamshaper 8 LCM model for image generation, while good enough, it did not present high adherence to the prompt/description of the RPG character. Therefore, I've had to switch to SDXL Lightning that takes into account much more of the details in the character description, provides a higher resolution results (1024px rather than 512px) and has a much more detailed and vibrant style.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Potential further development&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Enhanced Personalization:&lt;/strong&gt; I aim to further refine the UI to provide more personalized and diverse character creations based on user preferences and inputs. Perhaps using more diverse &lt;a href="https://www.mockofun.com/ai-image-generator-from-text/#:~:text=AI%20Character%20Generator-,AI%20Fantasy%20Portrait%20Generator,-You%20can%20now" rel="noopener noreferrer"&gt;AI character generator&lt;/a&gt; prompts would allow creating even more visual appealing characters.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Community Integration:&lt;/strong&gt; Introducing features that allow users to share and showcase their generated characters within a community setting is on the horizon. This will foster engagement and creativity among users.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Multi-modal Interactions:&lt;/strong&gt; Integrating voice and visual inputs to allow users to interact with the widget in more natural and immersive ways is another exciting avenue I plan to explore.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Multiple Models and/or Triple Task Types&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I've decided to use two models: a llm and a text to image model. I believe that orchestration of AI inference for different models is a very powerful tool. In my opinion this way of working with AI models is far more flexible and more resource efficient than using &lt;a href="https://huggingface.co/models?other=multimodal" rel="noopener noreferrer"&gt;multimodal AI models&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;At its core it is using 2 Cloudflare Workers AI models:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;LLM&lt;/strong&gt; - The &lt;em&gt;&lt;a href="https://developers.cloudflare.com/workers-ai/models/zephyr-7b-beta-awq/" rel="noopener noreferrer"&gt;zephyr-7b-beta-awq&lt;/a&gt;&lt;/em&gt; is a good choice as lightweight and fast text generation model. I use it for creating the textual information for the RPG character.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Image Generation&lt;/strong&gt; - The &lt;em&gt;&lt;a href="https://developers.cloudflare.com/workers-ai/models/dreamshaper-8-lcm/" rel="noopener noreferrer"&gt;dreamshaper-8-lcm&lt;/a&gt;&lt;/em&gt; or &lt;em&gt;&lt;a href="https://developers.cloudflare.com/workers-ai/models/stable-diffusion-xl-lightning/" rel="noopener noreferrer"&gt;stable-diffusion-xl-lightning&lt;/a&gt;&lt;/em&gt; are both good choices as lightweight and fast text generation models. They are text to image generators that are fast and appropriate for generating images (especially in the digital painting style). They are both a variations on the &lt;a href="https://stability.ai/stable-image" rel="noopener noreferrer"&gt;Stable Diffusion&lt;/a&gt; model, and LCM (Latent Consistency Model) is an optimization of the model which renders quality images with impressive speed. While the lightning version is also an accelerated model version of the SDXL mode. You can try with the other &lt;a href="https://developers.cloudflare.com/workers-ai/models/" rel="noopener noreferrer"&gt;text to image models&lt;/a&gt; just by replacing the &lt;code&gt;txt2img_model&lt;/code&gt; variable in the code.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>cloudflarechallenge</category>
      <category>devchallenge</category>
      <category>ai</category>
      <category>node</category>
    </item>
    <item>
      <title>Simple Face Swap Python Script (Free Download Available)</title>
      <dc:creator>codingdudecom</dc:creator>
      <pubDate>Sun, 24 Mar 2024 08:35:30 +0000</pubDate>
      <link>https://dev.to/codingdudecom/simple-face-swap-python-script-free-download-available-3lhk</link>
      <guid>https://dev.to/codingdudecom/simple-face-swap-python-script-free-download-available-3lhk</guid>
      <description>&lt;p&gt;Ever wanted to swap faces in images for fun or to create memes? This Python script makes it easy using OpenCV and dlib libraries. While there are more advanced methods available, like MockoFun’s &lt;a href="https://www.mockofun.com/face-swap/"&gt;online face swap&lt;/a&gt; app, this script offers a hands-on approach to understanding face swapping technology.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3oge2u88jjgxf9axx884.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3oge2u88jjgxf9axx884.jpg" alt="Face Swap Online" width="800" height="800"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;note: this image was made with MockoFun &lt;a href="https://www.mockofun.com/face-swap/"&gt;online face swap&lt;/a&gt; app, NOT with the script&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SCRIPT DOWNLOAD LINK:&lt;/strong&gt; &lt;a href="https://www.coding-dude.com/wp/ai/face-swap-python/"&gt;Face Swap Python&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Key Features:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Facial Landmark Detection:&lt;/strong&gt; Utilizes a pre-trained model to identify key facial features.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Face Alignment &amp;amp; Warping:&lt;/strong&gt; Aligns and overlays faces from two images for a seamless swap.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Color Correction:&lt;/strong&gt; Adjusts colors to match the target image for a natural look.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Usage:&lt;/strong&gt; Provide two image paths as command-line arguments to swap faces. The script is best with frontal, well-lit images4.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Ethical Considerations
&lt;/h2&gt;

&lt;p&gt;Use responsibly and respect privacy and consent. You should always ask for the consent of the people whose images you want to use for face swapping or make sure they are used in a context that clearly indicates the nature of the modified images.&lt;/p&gt;

&lt;h2&gt;
  
  
  Further Exploration
&lt;/h2&gt;

&lt;p&gt;For those interested in the technicalities, the script’s step-by-step breakdown and the science behind face swapping are detailed on the page. &lt;/p&gt;

&lt;p&gt;For more advanced techniques, I recommend &lt;a href="https://medium.com/@codingdudecom/deepfake-ai-face-swap-e11edc7d67e1"&gt;this article&lt;/a&gt;. It goes more in-depth explaining how AI face swap and deepswap works, the architecture of the neural networks and the principles for training it.&lt;/p&gt;

&lt;p&gt;As for the applications of the face swap script, one cool app is the &lt;a href="https://johana.gumroad.com/l/face-swap-in-photoshop"&gt;Face Swap for Photoshop&lt;/a&gt; action available for free on Gumroad.&lt;/p&gt;

&lt;p&gt;Drop me a comment if you have any questions or remarks. You can also find me here:&lt;/p&gt;

&lt;p&gt;Twitter: &lt;a href="https://twitter.com/codingdudecom"&gt;@codingdudecom&lt;/a&gt; &lt;br&gt;
Github: &lt;a href="https://github.com/codingdudecom/"&gt;https://github.com/codingdudecom/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>python</category>
      <category>opensource</category>
    </item>
    <item>
      <title>CSS Rainbow Text Effect To Spice Up Your Web Design</title>
      <dc:creator>codingdudecom</dc:creator>
      <pubDate>Fri, 03 Nov 2023 12:00:16 +0000</pubDate>
      <link>https://dev.to/codingdudecom/css-rainbow-text-effect-to-spice-up-your-web-design-18dk</link>
      <guid>https://dev.to/codingdudecom/css-rainbow-text-effect-to-spice-up-your-web-design-18dk</guid>
      <description>&lt;p&gt;&lt;strong&gt;ORIGINAL ARTICLE:&lt;/strong&gt; &lt;a href="https://www.coding-dude.com/wp/css/css-rainbow-text/" rel="noopener noreferrer"&gt;CSS Rainbow Text&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Imagine making your website or project look super cool with colorful text that looks like a rainbow. Learning how to do this using CSS (a fancy code for making things look good on the web) can be a fun and useful skill.&lt;/p&gt;

&lt;p&gt;In this article, I'll show you different ways to make this &lt;strong&gt;CSS rainbow text&lt;/strong&gt;, and I'll even make it move around with cool animations. I'll give you the secret code (HTML and CSS) to make it happen, and you can try it out on CodePen. So, get ready to learn and make your web stuff look awesome with rainbow text!&lt;/p&gt;

&lt;p&gt;So, here are 5 methods for creating a rainbow text effect:&lt;/p&gt;

&lt;h2&gt;
  
  
  Method 1 - Rainbow Text with CSS Linear Gradient
&lt;/h2&gt;

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

&lt;p&gt;Alternatively, we can make the rainbow without the gradient transitions and display the rainbow as stripes. &lt;/p&gt;

&lt;p&gt;Here’s the code and result of that:&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Method 2 - Rainbow Text In CSS Using Text Shadows
&lt;/h2&gt;

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

&lt;p&gt;I’m using the CSS variable &lt;code&gt;--shadow-space&lt;/code&gt; to offset each rainbow text color by a configurable amount. This method will come in handy below where I will show you how to create a CSS rainbow text animation.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;text-shadow&lt;/code&gt; can be used for multiple text effects. A while back I’ve shown &lt;a href="https://www.coding-dude.com/wp/css/css-stroke-text/" rel="noopener noreferrer"&gt;how to create a text outline&lt;/a&gt; using it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Method 3 - Rainbow Text Using CSS &amp;amp; Rainbow Texture
&lt;/h2&gt;

&lt;p&gt;This is probably the most commonly used method for making a rainbow text in CSS. Simply using an image or texture as the background image for a text and using the exact same method as for the CSS rainbow gradient text.&lt;/p&gt;

&lt;p&gt;This method is less flexible and it requires the rainbow texture image. Of course you can learn &lt;a href="https://www.psd-dude.com/tutorials/creating-a-cartoon-rainbow.aspx" rel="noopener noreferrer"&gt;how to make a rainbow in Photoshop&lt;/a&gt; or make one from scratch in &lt;a href="https://www.mockofun.com/" rel="noopener noreferrer"&gt;MockoFun&lt;/a&gt;. But, it might be simpler to just download this &lt;a href="https://www.textures4photoshop.com/tex/abstract/rainbow-pattern.aspx" rel="noopener noreferrer"&gt;free rainbow pattern&lt;/a&gt; or this &lt;a href="https://www.textures4photoshop.com/tex/abstract/rainbow-gradient.aspx" rel="noopener noreferrer"&gt;free rainbow gradient texture&lt;/a&gt; from Textures4Photoshop.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Method 4 - Use an Online Tool For Creating Rainbow Text
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.mockofun.com/template/rainbow-font-generator/" rel="noopener noreferrer"&gt;&lt;img src="https://media.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%2Fns5ympt6gqglnksd1cr0.gif" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The fastest and most convenient method to add a rainbow text effect in your HTML is by using a simple graphic design app like MockoFun. This app offers premade template, and as it happens it has an easy to use and 100% free &lt;a href="https://www.mockofun.com/template/rainbow-font-generator/" rel="noopener noreferrer"&gt;rainbow text generator&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You open it, input your text and download the end result as an image (JPG, WebP, PNG, etc). These images are perfectly fine to use in your HTML webpage instead of the making a pure CSS rainbow text.&lt;/p&gt;

&lt;p&gt;And now, some CSS animated rainbow text effects:&lt;/p&gt;

&lt;h2&gt;
  
  
  Animated Rainbow Gradient Text CSS
&lt;/h2&gt;

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

&lt;h2&gt;
  
  
  CSS Animated Rainbow Text Shadow
&lt;/h2&gt;

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

&lt;p&gt;In Conclusion&lt;br&gt;
So, now you know several methods how to make a HTML rainbow text with CSS. There are so many uses for a rainbow color text in web pages especially because the rainbow is a symbol for many things.&lt;/p&gt;

&lt;h2&gt;
  
  
  You can follow me
&lt;/h2&gt;

&lt;p&gt;My blog: &lt;a href="https://www.coding-dude.com/" rel="noopener noreferrer"&gt;coding-dude.com&lt;/a&gt;&lt;br&gt;
Twitter: &lt;a href="https://twitter.com/codingdudecom" rel="noopener noreferrer"&gt;@codingdudecom&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>text</category>
      <category>webdev</category>
      <category>design</category>
    </item>
    <item>
      <title>CSS Comic Book Style Speech Bubble</title>
      <dc:creator>codingdudecom</dc:creator>
      <pubDate>Thu, 05 Oct 2023 05:08:58 +0000</pubDate>
      <link>https://dev.to/codingdudecom/css-comic-book-style-speech-bubble-5h6a</link>
      <guid>https://dev.to/codingdudecom/css-comic-book-style-speech-bubble-5h6a</guid>
      <description>&lt;h2&gt;
  
  
  Speech Bubble CSS
&lt;/h2&gt;

&lt;p&gt;Creating speech bubbles with CSS is a simple job, but I made it simpler with this gist. Find the HTML &amp;amp; CSS code for it below. &lt;br&gt;
For more explanations on how it works check out my extended &lt;a href="https://www.coding-dude.com/wp/css/css-speech-bubbles/" rel="noopener noreferrer"&gt;CSS Speech Bubbles&lt;/a&gt; post on my &lt;a href="https://www.coding-dude.com/" rel="noopener noreferrer"&gt;CodingDude&lt;/a&gt; blog.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.coding-dude.com/wp/css/css-speech-bubbles/" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.coding-dude.com%2Fwp%2Fwp-content%2Fuploads%2F2023%2F09%2Fcss-speech-bubble.jpg" alt="CSS Speech Bubbles"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;inspired by &lt;a href="https://www.psd-dude.com/tutorials/resources/comic-strip-template.aspx" rel="noopener noreferrer"&gt;Comic Strip Template&lt;/a&gt; by &lt;a href="https://www.psd-dude.com/" rel="noopener noreferrer"&gt;PSDDude&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Speech Bubble HTML Code:
&lt;/h2&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;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"speech-bubble"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;CSS IS AWESOME!!! 💥 DON'T YOU THINK?&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;


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

&lt;/div&gt;
&lt;h2&gt;
  
  
  Speech Bubble CSS Code:
&lt;/h2&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;

&lt;span class="nc"&gt;.speech-bubble&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--arrow-w&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;0.5em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--arrow-h&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;1em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--bubble-corners&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="py"&gt;--w&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;12em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--border-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;3px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--text-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--bubble-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--border-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.speech-bubble&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;cursive&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;20px&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="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--text-color&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;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--bubble-color&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;1em&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;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--bubble-corners&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="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--w&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;0&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--border-size&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--border-color&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.speech-bubble.round&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--bubble-corners&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;1em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.speech-bubble.circle&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--bubble-corners&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;2em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.speech-bubble&lt;/span&gt;&lt;span class="nd"&gt;:before&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="nc"&gt;.speech-bubble&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="s1"&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;bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;-1&lt;/span&gt; &lt;span class="err"&gt;*&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-h&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="err"&gt;*&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="err"&gt;+&lt;/span&gt; &lt;span class="m"&gt;0.5px&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;50%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;solid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-h&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-w&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;border-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--bubble-color&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nb"&gt;transparent&lt;/span&gt; &lt;span class="nb"&gt;transparent&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.speech-bubble&lt;/span&gt;&lt;span class="nd"&gt;:before&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;border-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-h&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="err"&gt;+&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--border-size&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-w&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="err"&gt;+&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--border-size&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="nl"&gt;border-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--border-color&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nb"&gt;transparent&lt;/span&gt; &lt;span class="nb"&gt;transparent&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;-1&lt;/span&gt; &lt;span class="err"&gt;*&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-h&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="err"&gt;*&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="n"&gt;-&lt;/span&gt; &lt;span class="m"&gt;2.5&lt;/span&gt;&lt;span class="err"&gt;*&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--border-size&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="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;50%&lt;/span&gt; &lt;span class="n"&gt;-&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--border-size&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.speech-bubble.t&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;border-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;transparent&lt;/span&gt; &lt;span class="nb"&gt;transparent&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--bubble-color&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;auto&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="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;-1&lt;/span&gt; &lt;span class="err"&gt;*&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-h&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="err"&gt;*&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="err"&gt;+&lt;/span&gt; &lt;span class="m"&gt;0.5px&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.speech-bubble.t&lt;/span&gt;&lt;span class="nd"&gt;:before&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;border-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-h&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="err"&gt;+&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--border-size&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-w&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="err"&gt;+&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--border-size&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="nl"&gt;border-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;transparent&lt;/span&gt; &lt;span class="nb"&gt;transparent&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--border-color&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;auto&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="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;-1&lt;/span&gt; &lt;span class="err"&gt;*&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-h&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="err"&gt;*&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="n"&gt;-&lt;/span&gt; &lt;span class="m"&gt;2.5&lt;/span&gt;&lt;span class="err"&gt;*&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--border-size&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.speech-bubble.l&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;border-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;transparent&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--bubble-color&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nb"&gt;transparent&lt;/span&gt; &lt;span class="nb"&gt;transparent&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;auto&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-w&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-h&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="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;50%&lt;/span&gt; &lt;span class="n"&gt;-&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-w&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="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;-1&lt;/span&gt; &lt;span class="err"&gt;*&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-h&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="err"&gt;*&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="err"&gt;+&lt;/span&gt; &lt;span class="m"&gt;0.5px&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.speech-bubble.l&lt;/span&gt;&lt;span class="nd"&gt;:before&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;border-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-w&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="err"&gt;+&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--border-size&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-h&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="err"&gt;+&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--border-size&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="nl"&gt;border-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;transparent&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--border-color&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nb"&gt;transparent&lt;/span&gt; &lt;span class="nb"&gt;transparent&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;auto&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="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;50%&lt;/span&gt; &lt;span class="n"&gt;-&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-w&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;-&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--border-size&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="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;-1&lt;/span&gt; &lt;span class="err"&gt;*&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-h&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="err"&gt;*&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="n"&gt;-&lt;/span&gt; &lt;span class="m"&gt;2.5&lt;/span&gt;&lt;span class="err"&gt;*&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--border-size&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.speech-bubble.r&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;border-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;transparent&lt;/span&gt; &lt;span class="nb"&gt;transparent&lt;/span&gt; &lt;span class="nb"&gt;transparent&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--bubble-color&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;auto&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="nb"&gt;auto&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-w&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-h&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="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;50%&lt;/span&gt; &lt;span class="n"&gt;-&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-w&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="nl"&gt;right&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;-1&lt;/span&gt; &lt;span class="err"&gt;*&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-h&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="err"&gt;*&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="err"&gt;+&lt;/span&gt; &lt;span class="m"&gt;0.5px&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.speech-bubble.r&lt;/span&gt;&lt;span class="nd"&gt;:before&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;border-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-w&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="err"&gt;+&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--border-size&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-h&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="err"&gt;+&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--border-size&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="nl"&gt;border-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;transparent&lt;/span&gt; &lt;span class="nb"&gt;transparent&lt;/span&gt; &lt;span class="nb"&gt;transparent&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--border-color&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;auto&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="nb"&gt;auto&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="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;50%&lt;/span&gt; &lt;span class="n"&gt;-&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-w&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;-&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--border-size&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="nl"&gt;right&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;-1&lt;/span&gt; &lt;span class="err"&gt;*&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-h&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="err"&gt;*&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="n"&gt;-&lt;/span&gt; &lt;span class="m"&gt;2.5&lt;/span&gt;&lt;span class="err"&gt;*&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--border-size&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.speech-bubble.pop&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;animation-name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;animation-duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.5s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;animation-timing-function&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;cubic-bezier&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0.755&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0.050&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0.855&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0.060&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.speech-bubble.float&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;animation-name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;float-up&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;animation-duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;animation-iteration-count&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;infinite&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;animation-timing-function&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;ease&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.speech-bubble.r.float&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;animation-name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;float-left&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.speech-bubble.l.float&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;animation-name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;float-right&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.speech-bubble.t.float&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;animation-name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;float-down&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;@keyframes&lt;/span&gt; &lt;span class="n"&gt;pop&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;scale&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="err"&gt;80&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;scale&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1.1&lt;/span&gt;&lt;span class="p"&gt;);}&lt;/span&gt;
  &lt;span class="err"&gt;90&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;scale&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0.9&lt;/span&gt;&lt;span class="p"&gt;);}&lt;/span&gt;
  &lt;span class="err"&gt;100&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;scale&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="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;@keyframes&lt;/span&gt; &lt;span class="n"&gt;float-up&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translateY&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="err"&gt;50&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translateY&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;-1&lt;/span&gt; &lt;span class="err"&gt;*&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-h&lt;/span&gt;&lt;span class="p"&gt;)));}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;@keyframes&lt;/span&gt; &lt;span class="n"&gt;float-left&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translateX&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="err"&gt;50&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translateX&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;-1&lt;/span&gt; &lt;span class="err"&gt;*&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-h&lt;/span&gt;&lt;span class="p"&gt;)));}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;@keyframes&lt;/span&gt; &lt;span class="n"&gt;float-right&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translateX&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="err"&gt;50&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translateX&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-h&lt;/span&gt;&lt;span class="p"&gt;));}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;@keyframes&lt;/span&gt; &lt;span class="n"&gt;float-down&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translateY&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="err"&gt;50&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translateY&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--arrow-h&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;
  
  
  Speech Bubble CSS Classes &amp;amp; Customization
&lt;/h2&gt;

&lt;p&gt;Customize the Speech Bubble Design with Provided CSS Classes&lt;br&gt;
Use the following CSS classes together with the base .speech-bubble class:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;t&lt;/code&gt;, &lt;code&gt;l&lt;/code&gt;, &lt;code&gt;r&lt;/code&gt; or &lt;code&gt;b&lt;/code&gt; for placing the arrow top, left, right or bottom (by default the speech bubble arrow points downwards)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;round&lt;/code&gt; or &lt;code&gt;circle&lt;/code&gt; for bubble shape (by default the dialog box has square corners); TIP: Circle works best for dialog bubbles, because in old comic books and newspaper doodle drawings, that’s how they were drawn.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;pop&lt;/code&gt; or &lt;code&gt;float&lt;/code&gt; for animation (by default the text bubble is static)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Additional Customization via CSS Variables
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;--arrow-w&lt;/code&gt;: This variable sets the width of the arrow of the speech bubble to 0.5em.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--arrow-h&lt;/code&gt;: This variable sets the height of the arrow of the speech bubble to 1em.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--bubble-corners&lt;/code&gt;: This variable determines the roundness of the bubble’s corners. A value of 0 indicates sharp corners (so a square text bubble) while something like 50% would make a circle or elliptical talking bubble.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--w&lt;/code&gt;: This variable sets the maximum width of the speech bubble, which is 12em in this case.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--border-size&lt;/code&gt;: It defines the size or thickness of the border around the speech bubble, which is set to 3px.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--text-color&lt;/code&gt;: This variable sets the color of the text inside the speech bubble to black.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--bubble-color&lt;/code&gt;: It determines the background color of the speech bubble itself, which is set to white.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--border-color&lt;/code&gt;: This variable determines the color of the border around the speech bubble, also set to black.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Codepen Demo
&lt;/h2&gt;

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

&lt;h2&gt;
  
  
  You can follow me
&lt;/h2&gt;

&lt;p&gt;My blog: &lt;a href="https://www.coding-dude.com/" rel="noopener noreferrer"&gt;coding-dude.com&lt;/a&gt;&lt;br&gt;
Twitter: &lt;a href="https://twitter.com/codingdudecom" rel="noopener noreferrer"&gt;@codingdudecom&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Designing a Customizable Street Sign Using HTML and CSS</title>
      <dc:creator>codingdudecom</dc:creator>
      <pubDate>Wed, 06 Sep 2023 08:55:59 +0000</pubDate>
      <link>https://dev.to/codingdudecom/designing-a-customizable-street-sign-using-html-and-css-4jl0</link>
      <guid>https://dev.to/codingdudecom/designing-a-customizable-street-sign-using-html-and-css-4jl0</guid>
      <description>&lt;p&gt;&lt;strong&gt;ORIGINAL ARTICLE:&lt;/strong&gt; &lt;a href="https://www.coding-dude.com/wp/css/customizable-street-sign/"&gt;Customizable Street Sign&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Street signs are an essential part of urban landscapes, guiding us through cities and neighborhoods. But have you ever wanted to create your own unique street sign for a special occasion or just for fun? In this tutorial, we’ll show you how to design a stylish street sign using HTML and CSS, and even customize it by changing its color. This tutorial is inspired by the free online template &lt;a href="https://www.mockofun.com/template/street-sign-maker/"&gt;Street Sign Maker&lt;/a&gt; available on &lt;a href="https://www.mockofun.com/"&gt;MockoFun&lt;/a&gt;, an online graphic design application that makes creative design easy.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--G3O8mave--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.coding-dude.com/wp/wp-content/uploads/2023/09/customizable-street-sign.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--G3O8mave--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.coding-dude.com/wp/wp-content/uploads/2023/09/customizable-street-sign.webp" alt="Customizable Street Sign" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Getting Started with HTML
&lt;/h2&gt;

&lt;p&gt;Let’s start with the HTML structure for our street sign. We’ll keep it simple and use a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; element with the class “street-sign”. Here’s the HTML code:&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;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"street-sign"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;MOCKOFUN&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we’ve used the text &lt;strong&gt;“MOCKOFUN”&lt;/strong&gt; for our street sign, but you can replace it with any text of your choice.&lt;/p&gt;

&lt;h2&gt;
  
  
  Styling with CSS
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7ZMzJlfU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.coding-dude.com/wp/wp-content/uploads/2023/09/customizable-street-sign-green.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7ZMzJlfU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.coding-dude.com/wp/wp-content/uploads/2023/09/customizable-street-sign-green.webp" alt="Customizable Street Sign" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let’s dive into the CSS code that will make our street sign visually appealing and customizable. We’ll use CSS variables to make it easy to change the sign’s color. Here’s the CSS code:&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="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--green&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#145203&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--blue&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#0561ad&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--yellow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;#FDDA16&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--white&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;#FFFFFF&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="py"&gt;--superscript&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;"ST"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.street-sign&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--sign-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--green&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;40vh&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;white-space&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;nowrap&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="n"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;15vh&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;60px&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="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--sign-color&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="n"&gt;min-content&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;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;sans-serif&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="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.25em&lt;/span&gt; &lt;span class="m"&gt;0.25em&lt;/span&gt; &lt;span class="m"&gt;0.25em&lt;/span&gt; &lt;span class="m"&gt;0.5em&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;0.25em&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;0&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;0.1em&lt;/span&gt; &lt;span class="no"&gt;white&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;0&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0.1em&lt;/span&gt; &lt;span class="err"&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;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--sign-color&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="m"&gt;0.2em&lt;/span&gt; &lt;span class="m"&gt;0.2em&lt;/span&gt; &lt;span class="m"&gt;0.1em&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;0&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="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0.25&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.street-sign&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="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--superscript&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;0.5em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;vertical-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;super&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin-left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.5em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.street-sign.inverted&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;black&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;0&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;0.1em&lt;/span&gt; &lt;span class="no"&gt;black&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;0&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0.1em&lt;/span&gt; &lt;span class="err"&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;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--sign-color&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="m"&gt;0.2em&lt;/span&gt; &lt;span class="m"&gt;0.2em&lt;/span&gt; &lt;span class="m"&gt;0.1em&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;0&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="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0.25&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 the key components of this CSS code:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;CSS Variables&lt;/strong&gt;: We define color variables, &lt;code&gt;--green&lt;/code&gt; , &lt;code&gt;--blue&lt;/code&gt;, &lt;code&gt;--yellow&lt;/code&gt; and &lt;code&gt;--white&lt;/code&gt; which can be customized to change the sign’s color. Additionally, we define a &lt;code&gt;--superscript&lt;/code&gt; variable for the superscript text (e.g., “ST”).&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;&lt;code&gt;.street-sign&lt;/code&gt; Class&lt;/strong&gt;: This class styles our street sign. Here are some important style details:

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;--sign-color&lt;/code&gt;: This variable determines the background color of the sign. By default, it’s set to &lt;code&gt;--green&lt;/code&gt;, but you can easily change it to &lt;code&gt;--blue&lt;/code&gt; or any other color you prefer.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;margin&lt;/code&gt;, &lt;code&gt;white-space&lt;/code&gt;, and &lt;code&gt;font-size&lt;/code&gt; properties control the sign’s positioning and text size.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;background-color&lt;/code&gt; sets the background color based on the &lt;code&gt;--sign-color&lt;/code&gt; variable.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;color&lt;/code&gt; defines the text color as white.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;font-family&lt;/code&gt; and &lt;code&gt;font-weight&lt;/code&gt; determine the font used and its weight.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;padding&lt;/code&gt;, &lt;code&gt;border-radius&lt;/code&gt;, and &lt;code&gt;box-shadow&lt;/code&gt; add stylistic details to the sign.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;&lt;code&gt;.street-sign::after&lt;/code&gt; Pseudo-element&lt;/strong&gt;: This pseudo-element allows us to add a superscript (e.g., “ST”) to the sign. You can change the &lt;code&gt;--superscript&lt;/code&gt; variable to display different superscript text like “ROAD”, “RD”, “W”, “AVE”, “BLVD”, etc.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;&lt;code&gt;.street-sign.inverted&lt;/code&gt; Class:&lt;/strong&gt; is a CSS class that you can add for the yellow and white signs. These street signs will have a black text color and black border.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here’s a quick explanation about the code for the street sign border. In this case I’ve used CSS shadows, but if you read my &lt;a href="https://www.coding-dude.com/wp/css/css-stroke-text/"&gt;CSS Stroke Definitive Guide&lt;/a&gt; you’ll see there are many other ways to achieve this.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;css   .box-shadow: 0 0 0 0.1em white, 0 0 0 calc(0.1em + 1px) var(--sign-color), 0.2em 0.2em 0.1em rgba(0, 0, 0, 0.25);&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;In this line of CSS code, you’re applying multiple box shadows to the &lt;code&gt;.street-sign&lt;/code&gt; class to achieve a stylish border effect around the sign. Let’s break down each part of this box shadow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;First Shadow&lt;/strong&gt;: &lt;code&gt;0 0 0 0.1em white&lt;/code&gt; this is the white border of the street sign.

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;0&lt;/code&gt; for the horizontal offset: This means there is no horizontal offset, so the shadow appears directly behind the element.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;0&lt;/code&gt; for the vertical offset: Similarly, there’s no vertical offset, so the shadow is right behind the element.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;0&lt;/code&gt; for the blur radius: The blur radius is set to zero, which means the shadow has a sharp edge.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;0.1em&lt;/code&gt; for the spread radius: The spread radius creates a border-like effect by expanding the shadow by a small distance of &lt;code&gt;0.1em&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;white&lt;/code&gt; for the shadow color: This part of the shadow is white, which creates the appearance of an inner border.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Second Shadow&lt;/strong&gt;: &lt;code&gt;0 0 0 calc(0.1em + 1px) var(--sign-color)&lt;/code&gt; this is the outside edge of the street sign which is the same color as the street sign itself.

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;0&lt;/code&gt; for the horizontal and vertical offset: No horizontal or vertical offset is applied.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;0&lt;/code&gt; for the blur radius: There’s no blur effect.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;calc(0.1em + 1px)&lt;/code&gt; for the spread radius: This dynamically calculates the spread radius to be slightly larger than the previous shadow, creating an outer border effect.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;var(--sign-color)&lt;/code&gt; for the shadow color: This part of the shadow takes on the color defined by the &lt;code&gt;--sign-color&lt;/code&gt; variable, allowing you to customize the border color.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Third Shadow&lt;/strong&gt;: &lt;code&gt;0.2em 0.2em 0.1em rgba(0, 0, 0, 0.25)&lt;/code&gt; this is an extra effect creating a diffuse drop shadow effect for the entire street sign.

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;0.2em&lt;/code&gt; for the horizontal offset: A slight horizontal offset of &lt;code&gt;0.2em&lt;/code&gt; gives the appearance of a shadow to the right and below the sign.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;0.2em&lt;/code&gt; for the vertical offset: Similarly, a vertical offset of &lt;code&gt;0.2em&lt;/code&gt; creates a shadow to the right and below the sign.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;0.1em&lt;/code&gt; for the blur radius: This adds a subtle blur effect to the shadow.&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;rgba(0, 0, 0, 0.25)&lt;/code&gt; for the shadow color: The shadow is semi-transparent and dark, which creates a shadowed effect to give depth to the sign.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In summary, by combining these multiple box shadows, you create a visually appealing border effect for the street sign. The first shadow is an inner border, the second shadow is an outer border, and the third shadow provides a subtle drop shadow effect, resulting in a polished and stylish appearance for the sign.&lt;/p&gt;

&lt;h2&gt;
  
  
  Customizing the Street Sign’s Color
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PAbyOR3E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.coding-dude.com/wp/wp-content/uploads/2023/09/customizable-street-sign-all-colors.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PAbyOR3E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.coding-dude.com/wp/wp-content/uploads/2023/09/customizable-street-sign-all-colors.webp" alt="Customizable Street Sign" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To customize the sign’s color, simply change the value of the &lt;code&gt;--sign-color&lt;/code&gt; variable in the &lt;code&gt;:root&lt;/code&gt; section of your CSS. For example, to make the sign blue, update it like this:&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="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--green&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#145203&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--blue&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#0561ad&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="py"&gt;--superscript&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;"ST"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.street-sign&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--sign-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--blue&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="err"&gt;/\*&lt;/span&gt; &lt;span class="err"&gt;Change&lt;/span&gt; &lt;span class="err"&gt;to&lt;/span&gt; &lt;span class="err"&gt;blue&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;You can experiment with different color values to create a street sign that matches your preferences or the theme of your project. For some light colors you might need to use the .inverted CSS class in order to have a black text and border.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--opSVhXgj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.coding-dude.com/wp/wp-content/uploads/2023/09/customizable-street-sign-white-300x225.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--opSVhXgj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.coding-dude.com/wp/wp-content/uploads/2023/09/customizable-street-sign-white-300x225.webp" alt="Customizable Street Sign" width="300" height="225"&gt;&lt;/a&gt; &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rotEVGG4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.coding-dude.com/wp/wp-content/uploads/2023/09/customizable-street-sign-yellow-300x225.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rotEVGG4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.coding-dude.com/wp/wp-content/uploads/2023/09/customizable-street-sign-yellow-300x225.webp" alt="Customizable Street Sign" width="300" height="225"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it on CodePen!
&lt;/h2&gt;

&lt;p&gt;Want to see and experiment with this street sign project in action? You can find the code on &lt;a href="https://codepen.io/inegoita/pen/OJrbQyO"&gt;CodePen&lt;/a&gt;. Feel free to customize it, change the text, or explore different color options right in your browser. Have fun designing your own street signs!&lt;/p&gt;

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

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

&lt;p&gt;Creating a stylish and customizable street sign using HTML and CSS is a fun way to add a personal touch to your web projects. This tutorial, inspired by MockoFun’s street sign template, provides a solid foundation to get you started. Whether you want to design a playful sign for an event or add a unique element to your website, have fun designing your own street signs!&lt;/p&gt;

</description>
      <category>css</category>
      <category>tutorial</category>
      <category>learning</category>
      <category>codepen</category>
    </item>
    <item>
      <title>Simple CSS Threshold Filter</title>
      <dc:creator>codingdudecom</dc:creator>
      <pubDate>Mon, 14 Aug 2023 13:32:22 +0000</pubDate>
      <link>https://dev.to/codingdudecom/simple-css-threshold-filter-3c5d</link>
      <guid>https://dev.to/codingdudecom/simple-css-threshold-filter-3c5d</guid>
      <description>&lt;p&gt;Original article on Coding-Dude.com: &lt;a href="https://www.coding-dude.com/wp/css/css-threshold-filter/" rel="noopener noreferrer"&gt;CSS Threshold Filter&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are many applications that have a threshold tool including Photoshop, GIMP, etc. There are even free online applications that allow you to apply a threshold filter to an image online. For example the &lt;a href="https://www.mockofun.com/template/stencil-maker-from-photo/" rel="noopener noreferrer"&gt;stencil maker&lt;/a&gt; from MockoFun is a cool example of a free online application. It basically applies the threshold filter to any photo and transforms it into a stencil like the famous Bansky street art designs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.mockofun.com/template/stencil-maker-from-photo/" rel="noopener noreferrer"&gt;Stencil Maker&lt;/a&gt; on &lt;a href="https://www.mockofun.com/" rel="noopener noreferrer"&gt;MockoFun&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.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%2Fv02k9fpzjdiaefrl0bim.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fv02k9fpzjdiaefrl0bim.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  CSS Threshold Filter - The Code
&lt;/h2&gt;

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

&lt;p&gt;So, the HTML code is just a simple image:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;img src="https://i.imgur.com/r4csVkj.jpeg" alt="CSS Stencil Filter" class="threshold"&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;we've added the CSS class name threshold which is where we will place our CSS threshold filter code:&lt;/p&gt;

&lt;p&gt;`:root{&lt;br&gt;
--threshold:50%;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;.threshold{&lt;br&gt;
filter: brightness(calc(100% + var(--threshold))) grayscale(100%) contrast(1000%);&lt;br&gt;
}`&lt;/p&gt;

&lt;p&gt;So, let’s take a look at this code and explain a bit what’s going on.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;:root{ --threshold:50%; }&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;This line sets a CSS variable named &lt;code&gt;--threshold&lt;/code&gt; in the root of the document, which acts as a threshold value for the filter. In this case, the threshold value is set to 50%, indicating that pixels with grayscale values below 50% will turn black, and those above 50% will turn white.&lt;/p&gt;

&lt;p&gt;This variable is optional, as you could simply put in the value in the &lt;code&gt;.threshold&lt;/code&gt; class CSS code, but it’s a convenient way of separating the value for the threshold. This is especially useful if you want to make the threshold dynamic, as I’ve done in my code. Changing the threshold is as easy as changing this CSS variable.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;.threshold{ ... }&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;This CSS class selector targets elements with the class name “threshold” and applies a series of filter effects to them. The effects combine to create the threshold filter.&lt;/p&gt;

&lt;p&gt;Let’s break it down:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;brightness(calc(100% + var(--threshold)))&lt;/code&gt;: Here, the brightness filter is used to adjust the overall brightness of the image. The calc() function combines the original brightness (100%) with the custom threshold value stored in the --threshold variable. This effectively brightens the pixels that are above the threshold value.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;grayscale(100%)&lt;/code&gt;: The grayscale filter is applied at maximum intensity (100%), converting the image to grayscale.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;contrast(1000%)&lt;/code&gt;: The contrast filter is used to enhance the contrast between black and white pixels by increasing the contrast level to 1000% – a large enough value to produce only black and white pixels, which is what we need for our threshold filter.&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;In web design, the CSS Threshold Filter is a very versatile tool for sophisticated photo effects. Using this simple filter you can achieve some really cool effects that will make your designs stand out.&lt;/p&gt;

&lt;p&gt;As we conclude this journey, remember that CSS filters are a gateway to limitless creativity. Experimentation is your compass, leading you to explore beyond thresholds. Why not venture into applying &lt;a href="https://www.coding-dude.com/wp/css/css-image-effects/" rel="noopener noreferrer"&gt;vintage photo filters using CSS&lt;/a&gt; or merging various filters for breathtaking effects? The canvas is yours to paint, and the possibilities are boundless. Embrace innovation, and let the CSS Threshold Filter be the stepping stone to your design masterpiece. Unleash the power of code to transform the ordinary into the extraordinary, and watch your web designs come alive like never before.&lt;/p&gt;

&lt;p&gt;Follow me on DEV: &lt;a class="mentioned-user" href="https://dev.to/codingdudecom"&gt;@codingdudecom&lt;/a&gt;&lt;br&gt;
Follow me on Twitter/X: &lt;a href="https://www.twitter.com/codingdude.com" rel="noopener noreferrer"&gt;@codingdudecom&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>tutorial</category>
      <category>code</category>
    </item>
    <item>
      <title>Gradient Text CSS</title>
      <dc:creator>codingdudecom</dc:creator>
      <pubDate>Sun, 02 Apr 2023 05:57:17 +0000</pubDate>
      <link>https://dev.to/codingdudecom/gradient-text-css-4cfl</link>
      <guid>https://dev.to/codingdudecom/gradient-text-css-4cfl</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.gradient-text {
   background-image: linear-gradient(to right, #833ab4, #fd1d1d,#fcb045);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;In the above example, we apply the &lt;code&gt;linear-gradient()&lt;/code&gt; function to the &lt;code&gt;background-image&lt;/code&gt; property, and then set the &lt;code&gt;background-clip&lt;/code&gt; property to text and the text-fill-color property to transparent. This tells the browser to apply the gradient to the text itself, and make the text color transparent so that the gradient shows through.&lt;/p&gt;

&lt;p&gt;You can actually create gradient text in HTML in several other ways. &lt;/p&gt;

&lt;p&gt;Check out the full article about &lt;a href="https://www.coding-dude.com/wp/css/gradient-text/"&gt;gradient text&lt;/a&gt;&lt;/p&gt;

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