Artifacts Gallery Guilds Search Wiki Login Register

Welcome, Guest. Please login or register. - Thinking of joining?
Autumn, 18 Nov 2026 - @898.73
Forum Activity: Four Stars Random | Recent Posts | Guild Recents
News: inconvenience is counterculture :eyes: Guild Events: November 200 words RPG jam
+  MelonLand Forum
|-+  Da Web Revival
| |-+  ✁ ∙ Web Crafting
| | |-+  Making animated GIF banners/blinkies/88×31s etc... using HTML and CSS!!


« previous next »
Pages: [1] Print Embed
Author Topic: Making animated GIF banners/blinkies/88×31s etc... using HTML and CSS!!  (Read 93 times)
Dan Q
Hero Member ⚓︎
*****
View Profile WWWArt


I have no idea what I am doing
⛺︎ My Room
RSS: RSS

Guild Memberships:
Artifacts:
Caught by RubbereonThe Worm is creeping around Melonland profiles!Dan Q Cruisin'I DIDN'T meet Dan Q on Melonland!Visited on Melon's 10th Anniversary!
« on: Autumn, 17 Nov 2026 @476 » Toggle Font Embed

Last week, I added some banners to MelonLand's Banner Club (and started hosting the banners on my site, of course!). Here's one, for example:

https://brain.melonking.net/banners/club-400x40/Dan_Q-6af4a9914331f.gif

Thing is... I'm not very good at graphic editing  :sad:. I'm much stronger with HTML + CSS (with perhaps a little SVG and JavaScript). So I did what any sensible person would do...

I made a program that can turn (almost) any Web "thing" into an animated GIF!

Here was my thinking:

  • I'll make my banners in HTML, then
  • I'll screenshot then a few hundred times over the course of a few seconds and combine those screenshots into a GIF (and then optimize it, of course, to get rid of unnecessary frames and generally make the file smaller!)

Step 1: making my banner

Making a 400 × 40 banner in HTML + CSS is pretty easy. Just make a web page with something like this on it:

Code
<div id="sample-banner"
  style="position: relative;
         overflow: hidden;
         width: 400px;
         height: 40px;">
  <!-- later, banner content will go here! -->
</div>

That's a 400 × 40 box. The position: relative; means that if I give everything inside it position: absolute;, I can position the things inside it relative to the banner. The overflow: hidden; ensures that anything that's "too big" for the banner gets clipped, rather that it being resized to fit the banner or the banner being resized to fit it.

Then I just started putting things inside it, using my browser's debug tools to tweak the CSS and move them around until I was happy. Like: the text on the right of my banner? Here's the code I used to create that:


Code
<div style="position: absolute; top: 1px; right: 21px; width: 50%; font-size: 14px; text-align: right; line-height: 18px; letter-spacing: 0.5px;">
  working to make the
  <br>
  Internet fun and weird
</div>

Notice the position: absolute; that allows me to use top: and right: (I could also use e.g. bottom: or left:) to position the text anywhere I want relative to the banner's edges.

I added an SVG of me, waving (the waving animation is powered by CSS) that I use elsewhere on the site, but I could equally have used e.g. conventional images, or emoji, or even JavaScript to make an animated background or randomise things! Anything I can do on the Web, I can do in the banner!

Step 2: turning it into a GIF

The clever bit is turning that banner, made out of general purpose web technologies, into a GIF! Here's the program I wrote (you're welcome to take a copy for yourself if you want). Here's how to install it, if you want it:


  • Install NodeJS, if you haven't already. (NodeJS is a JavaScript interpreter than runs on the command-line, not in your browser. I'm using Node v24, but any version from v18 onwards will probably work.)
  • Download my program into a directory by itself.
  • In that directory, run npm init -y; npm pkg set type=module; npm install puppeteer pngjs gifenc to install everything my program depends upon; specifically it's installing Puppeteer, PNGJS, and GIFEnc. (Puppeteer lets my program remote-control a web browser to get the screenshots it needs; PNGJS or GIFEnc are used to save the resulting images.)

Now it's ready to run! My banner needs to be on a web page with a web address I know (it can be localhost!), and it needs an id="..." attribute, e.g. id="my-banner". Then I can run:

Code
node generate.js https://example.com/page#my-banner 3.5 70 output-file.gif

In that command:

  • ht​tps://example.com/page is the web address of the page my "banner" is on
  • my-banner is its ID (note the # between it and the URL: just like if you were deep-linking to the banner!)
  • 3.5 is the number of "seconds" to record for
  • 70 is the number of "frames" to capture over that period, equally-spaced (70 frames over 3.5 seconds is 20 frames per second)
  • output-file.gif is the file to create

It only takes a few seconds to run, so it's easy to tweak the parameters until you get something you like.

Step ∞?: turning almost any bit of your website into a GIF

Because all it's doing is rapidly-screenshotting web pages, it works with anything. Watch as I transform parts of some maybe-familiar websites into animated GIFs with a single command:


Code
node generate.js "https://forum.melonland.net/#bunting" 2.1 75 melonland-bunting.gif


Code
node generate.js "https://melonking.net/melon#mainframe" 10 25 melonking-plot.gif


Code
node generate.js "https://ascending.danq.dev/#scene" 4.3 25 ascending.gif


:ozwomp: Important: the GIFs this produces are big; run them through Ezgif Optimizer or something to make the files smaller before you publish them! :ozwomp:

Want more?

I've no idea if this is useful for anybody other than me. Personally, I love the fact that I can now design banners, 88×31s, blinkies, or whatever else using HTML and CSS (and optionally SVG, images, JS, etc.), and then convert them into GIFs. It also means I can make changes easily: if I want to change the colour of my shirt in the banner, that's one CSS variable; if I want to change the text, that's plain text in a HTML file... and I can just run the same command again to get a fresh GIF!

Let me know if it helps you! Or if you've got improvements to it (maybe I should embed LossyGIF/Gifsicle right into it so it makes better-sized GIFs to begin with? or maybe I should allow generic selectors, not just IDs?)!

I've taken a deeper-dive on my blog with some more hands-on examples of how I'm using it.

Logged

https://danq.me/_q26t/badges/dan-q-88x31-lighter.gif https://danq.me/_q26t/badges/dan-q-88x31-peekaboo-scroller.gif https://beige-buttons.danq.dev/beige-buttons-88x31.gif https://embed-html.danq.dev/embed-html-88x31.gif https://origami.danq.dev/88x31.gif https://skelly.monster/dem-bones-88x31.gif

Artifact Swap: Pink ham-ham rangerPolyamorousI met Dan Q on Melonland!shoeJoined 2025!cinnamoroll
Pages: [1] Print Embed 
« previous next »
 

Melonking.Net © Always and ever was! SMF © 2021 | Privacy Notice | Send Feedback | Supporters ♥ Guide | Rules | Whos a Mod? | RSS | WAP | Mobile


MelonLand Badges and Other Melon Sites!

MelonLand Project! Visit the MelonLand Forum! Support the Forum
Visit Melonking.Net! Visit the Gif Gallery! Pixel Sea TamaNOTchi
@000 Melon
Land
Forum Art Hub Chat Webring Explore Random Recent Tenement Arcade Want to Login or Join ? Web Craft Guide Graphic Catalogue Wiki Help I'm Lost! Link Land Newsletters Image Stream Minecraft: Online
Zap!
Passport Sites tamaNOTchi Asatte Add your site?
Aero Archive Onio Cafe 32 Bit Cafe Status Cafe