Recreating Legendary 8-bit Games Music with the Web Audio API

Greg Hovanesyan, who recently posted here an Introduction to the Web Audio API, follows up with another huge post on how to use it to create iconic music from our nerds past, like sounds from The Legend of Zelda and Metroid. The final demo comes as a project you can explore. And don’t miss our recent roundup of some of the best Web Audio API Pens ever on CodePen. Direct Link to Article — PermalinkRecreating Legendary 8-bit Games Music with the Web Audio API is a post from CSS-Tricks

Continue Reading
s_7887F2C7EE34D61FF16137826B5D88AC920BD1E146FAAC42AB4B6AB5B2DEAC6D_1488871641697_Terminology2x

Building a CSS Grid Overlay

Let’s take a look at what it takes to build a grid overlay with CSS. It will be responsive, easily customizable and make heavy use of CSS variables (known more accurately as « CSS custom properties »). If you aren’t familiar with custom properties, I’d highly recommend reading What is the difference between CSS variables and preprocessor variables? and watching Lea Verou’s enlighting talk on using them. This grid overlay that we’re building will consider a developer tool, as in, a tool just for us, not really our users. So, let’s not worry too much about browser support (If you do care, check out caniuse… data on custom properties). While it’s impossible… Read More

Continue Reading
UfVrlid

Introduction to The Elm Architecture and How to Build our First Application

Creating our first Elm application might seem like a hard task. The new syntax and the new paradigm can be intimidating if you haven’t used other functional programming languages before. But once you create your first application, you will understand why Elm has been gaining so much attention lately. Article Series: Why Elm? (And How To Get Started With It) Introduction to The Elm Architecture and How to Build our First Application (You are here!) In this article, we are going to build a simple application that will introduce us to the language fundamentals: the Elm architecture and how to start making things. It is going to be pretty simple,… Read More

Continue Reading

Need to Catch Up on the AMP Debate?

The subject of AMP came up at a meetup I was at the other day. It came up in a « Hey have y’all seen this thing yet? » context. Some people have heard of it, some hadn’t. Even among those who had heard of it, the vibe was mostly: « this is newfangled tech. It’s the future, probably. I guess it’s a thing I gotta learn, I just haven’t gotten around to it yet. » Which makes sense. It’s just like hearing about some new JavaScript framework that is taking off. « Obviously, it’s a big deal, I just haven’t gotten there yet. Perhaps I will one day when it’s clear I need to… Read More

Continue Reading

Modern JavaScript for Ancient Web Developers

Gina Trapani: … when you’re learning modern JavaScript, there’s a good chance that the solution to the problem you’re having is still getting worked out. In fact, it’s very possible it is only one code review away from getting merged into the package you’re using. It’s a weird time. So many of us are living so close to the edge. As Gina puts it, it’s harder to find « a 5-year-old Stack Overflow answer that solves » your problem. New things drop and go out to production instantly, which is a bit at-odds with the classic wisdom of waiting for the .1 release. Direct Link to Article — PermalinkModern JavaScript for Ancient… Read More

Continue Reading
fontface-2

You Kinda Can Use Custom Fonts in HTML Emails

And you use them pretty much just like you’d use custom fonts on a website. Jaina Mistry had the scoop on this last year over on the Litmus blog: While web fonts don’t have universal support, here are the email clients where they are supported: AOL Mail Native Android mail app (not Gmail app) Apple Mail iOS Mail Outlook 2000 Outlook.com app Aside from using a JavaScript font loader, which definitely won’t work in email (no email client will be executing JavaScript), ultimately it comes down to @font-face in CSS. So let’s do that. Say we wanted to use Lato in an email, if we can. Go do the normal… Read More

Continue Reading

The Next Smashing Magazine

Congrats to the big team over there assembled to take on this major redesign process. Unlike our redesigns around here that are usually more like realignments with minor dev work and UX sprinkles each iteration, this was a ground-up rebuild for them. They migrated a bunch of different platforms all into one, a static-site based system with all front end APIs. It’s gotta feel good to pull all that stuff into one system. I remember when I used to have four different systems around here (WordPress, Forums (various), eCommerce (various), and some raw PHP stuff) and the good feeling it was to get it all yanked in under one WordPress… Read More

Continue Reading
selectable

Text Effects with CSS (and a little contenteditable trick)

Mandy Michael has been creating some incredible text effects with just the power of CSS. She uses every trick in the book: gradients, transforms, pseudo elements, shadows, and clipping paths to name a few. They are all real web text too. Custom fonts typically, but no images, canvas, or SVG or anything like that. Take a look at this beautiful effect: See the Pen CSS only 3D paper fold text effect by Mandy Michael (@mandymichael) on CodePen. The fact that it is real text makes it accessible, searchable, and of course, selectable: Demos are an awesome place to use the contenteditable attribute, which turns any text element into sort of… Read More

Continue Reading
p5-book-cover

Creating a Book Cover Using JavaScript and p5.js

I recently published a book and an interactive course called Coding for Visual Learners. It teaches coding to beginners from scratch using the widely popular JavaScript programming language and the p5.js programming library. Since p5.js a great and an easy to use drawing library, I wanted to make use of it to create the cover of my book and course as well. This is a tutorial on how to create this particular visual using JavaScript and p5.js. p5.js is a drawing & creative coding library that is based on the idea of sketching. Just like how sketching can be thought of as a minimal approach to drawing to quickly prototype… Read More

Continue Reading

Guetzli

Geutzili, Google’s new open source algorithm… …that creates high-quality JPEG images with file sizes 35% smaller than currently available methods, enabling webmasters to create webpages that can load faster and use even less data. I’ve seen this fairly widely reported, and that’s great because images are the main cause of web bloat these days and fighting back with tech seems smart. I also saw Anselm Hannemann note: This is great, but to put things into perspective, we also have to consider that it’s up to 100 times slower as Mozilla’s mozJPEG encoder and in many cases, it doesn’t achieve the same quality at the same file size Source: Kornel Lesiński,… Read More

Continue Reading

Animate in Ajax’d Content to its Natural Height

Let’s combine three things we just learned here on CSS-Tricks: One, transitioning to auto dimensions. Two, Ajaxing for stuff in a modern way. Three, waiting for images to be loaded to measure them. With all these three things in our toolbox, we can Ajax for some arbitrary content and insert it onto the page with a revealing height animation. Tricky tricky! Here’s the final demo: See the Pen Slide in Ajax Content by Chris Coyier (@chriscoyier) on CodePen. The thinking here is that since we’re guaranteed to be using JavaScript anyway, since we’re Ajaxing for some content, we might as well keep using JavaScript to help us make a smooth… Read More

Continue Reading

Need to do Dependency-Free Ajax?

One of the big reasons to use jQuery, for a long time, was how easy it made Ajax. It has a super clean, flexible, and cross-browser compatible API for all the Ajax methods. jQuery is still mega popular, but it’s becoming more and more common to ditch it, especially as older browser share drops and new browsers have a lot of powerful stuff we used to learn on jQuery for. Even just querySelectorAll is often cited as a reason to lose the jQuery dependency. How’s Ajax doing? Let’s say we needed to do a GET request to get some HTML from a URL endpoint. We aren’t going to do any… Read More

Continue Reading

Measuring Image Widths in JavaScript (Carefully!)

Let’s say you want to find an on the page and find out how wide it is in JavaScript. Maybe you need to make some choices based on that width (or height, or both) You can definitely do that. The DOM will even give you a variety of dimensions to choose from depending on what you need. There is definitely a catch though. Here’s the image: And here’s us selecting it, by finding the first JavaScript can find in the DOM: var img = document.querySelector(« img »); Let’s just log the width: // How wide the image is rendered at (which could be affected by styles) console.log(img.width); // How wide the image… Read More

Continue Reading
minesweeper-webvr-demo

Minecraft in WebVR with HTML Using A-Frame

I’m Kevin Ngo, a virtual reality web developer on the Mozilla VR team and a core developer of A-Frame. Today, we’ll go over how to build a room scale WebVR Minecraft demo that works on HTC Vive, Oculus Rift, Samsung GearVR, Google Cardboard, desktop, and mobile. The demo will be built with A-Frame in just 11 HTML elements! A-Frame A few years ago, Mozilla invented and pioneered WebVR, a JavaScript API for creating immersive VR experiences in your browser, in an experimental build of Firefox. Since then, WebVR has gained wide support from other companies such as Google, Microsoft, Samsung, and Oculus. And it’s now set to release enabled by… Read More

Continue Reading

Scrolling on the Web: A Primer

Scrolling is complicated. Nolan Lawson: User scrolls with two fingers on a touch pad User scrolls with one finger on a touch screen User scrolls with a mouse wheel on a physical mouse User clicks the sidebar and drags it up and down User presses up, down, PageUp, PageDown, or spacebar keys on a keyboard As it turns out, all five of these input methods have vastly different characteristics, especially when it comes to performance and cross-browser behavior. Some of them (such as touch screen scrolling) are likely to be smooth even on a page with heavy JavaScript usage, whereas others (such as keyboard scrolling) will make the same page… Read More

Continue Reading

Hassle-free Full Bleed with *:not()

Common situation documented by Dave Rupert: Let’s say you’re making a blog post layout. Content is entered into a CMS inside a WYSIWYG editor field. You echo that content to the page. You pull it up on a mobile device and notice the paragraphs go edge-to-edge. Yikes, it’s a little uncomfortable. So you add some kind of left/right padding maybe using a div.container. This works great until the client asks for the images and video to go full bleed. Your universal padding solution no longer works well. You got options. Containerizing isn’t great in any scenario. So how do you yank out those full bleed elements? Dave does it with… Read More

Continue Reading
no-cloud

“Serverless”

Every time I use the word « serverless », which is somewhat regularly lately, as we’ve had a few articles using the term lately and use the concept at CodePen for a variety of things, I get some version of: CMON BRAH YOU’RE STILL USING « SERVERS ». And they aren’t wrong. Yes, when you build things on the web, there are always servers involved. Always. Whether it’s some old computer in a church basement, a computer in a rack at some big hosting company, or « The Cloud », it’s a server. Chris Wattersons’s classic sticker.I rolled my eyes at the term the first few times I heard it too. But now I’m hesitant to… Read More

Continue Reading
auto-problem

Using CSS Transitions on Auto Dimensions

We’ve all been there. You’ve got an element you want to be able to collapse and expand smoothly using CSS transitions, but its expanded size needs to be content-dependent. You’ve set transition: height 0.2s ease-out. You’ve created a collapsed CSS class that applies height: 0. You try it out, and… the height doesn’t transition. It snaps between the two sizes as if transition had never been set. After some fiddling, you figure out that this problem only happens when the height starts out or ends up as auto. Percentages, pixel values, any absolute units work as expected. But all of those require hard coding a specific height beforehand, rather than… Read More

Continue Reading
Screenshot-2017-03-12-00.31.26

Getting Started with CSS Grid

This was a blockbuster week for front-end developers as CSS Grid landed in the latest versions of Firefox and Chrome without a feature flag. That’s right: we can now go and play with Grid in two of the most popular browsers right away. But why is CSS Grid a big deal and why should we care? Well, CSS Grid is the first real layout system for the web. It’s designed for organizing content both into columns and rows and it finally gives developers almost God-like control of the screens before us. That means that we can finally ditch decades of hacks and workarounds for setting elements on a web page… Read More

Continue Reading
large

Simple Little Use Case for `vmin`

Viewport units are things like 10vw (10% of the viewport width) or 2vh (2% of the viewport height). Useful sometimes, as they are always relative to the viewport. No cascading or influence by parent elements. There is also vmin, which is the lesser of vw and vh, and vmax, which is the greater. These values can be used for anything that takes a length value, just like px or em or % or whatever. Let’s take a look at a tiny design pattern that makes use of vmin. A header block! If we set the padding of an like so: header { padding: 10vmin 1rem; } We get some fixed… Read More

Continue Reading
h

The Document Outline Dilemma

For the past few weeks there has been lots of talk about HTML headings in web standards circles. Perhaps you’ve seen some of the blog posts, tweets, and GitHub issue threads. Headings have been part of HTML since the very first websites at CERN, so it might be surprising to find them controversial 25 years later. I’m going to quickly summarize why they are still worth discussing, with plenty of links to other sources, before adding my own opinions to the mix. If you’re up-to-date on the debate, you can jump straight to the « Bigger Dilemma » section. The Story So Far… HTML uses headings (, , , and so on… Read More

Continue Reading
tinymce

Build a Custom Serverless CMS: Part 2

In our previous proof-of-concept demo, we built a bare bones admin for generating a web page with the ability to edit some text on the page and set the site title and description. For this next demo, we build on our example and add rich text editing and image upload capabilities. Article Series: Build a Custom CMS for a Serverless Static Site Generator + Repo Build a Custom Serverless CMS: Part 2 (you are here!) + Repo Rich Text Editing TinyMCE is the most widely used web-based Rich Text Editor around, so let’s use it. We can add it to our admin form pretty easily. There are many configuration options… Read More

Continue Reading
workflow

Introduction to Web Audio API

Web Audio API let’s us make sound right in the browser. It makes your sites, apps, and games more fun and engaging. You can even build music-specific applications like drum machines and synthesizers. In this article, we’ll learn about working with the Web Audio API by building some fun and simple projects. Getting Started Let’s do some terminology. All audio operations in Web Audio API are handled inside an audio context. Each basic audio operation is performed with audio nodes that are chained together, forming an audio routing graph. Before playing any sound, you’ll need to create this audio context. It is very similar to how we would create a… Read More

Continue Reading

Randomizing SVG Shapes

SVG shapes are all built from numbers. Obvious, perhaps, but also, I’m not sure we take as much advantage of that as we could with inline . For example, it’s pretty easy to generate a new pseudo-random number in JavaScript: function getRandomInt(min, max) { return Math.floor(Math.random() * (max – min + 1) + min); } Now imagine a bunch of variables set to random numbers, and using ES6 template literals to stitch them together: let newPoints = `${x1},${y1} {x2},${y2} {x3},${y3} {x3},${y3}`; Which makes a valid syntax for the points attribute of a . let polygon = document.querySelector(« polygon »); polygon.setAttribute(« points », newPoints); A more detailed example of that, and a demo, over on… Read More

Continue Reading
cathy_oneil-620x412

Weapons of Math Destruction

I think you’d do well to read Cathy O’Neils Weapons of Math Destruction: How Big Data Increases Inequality and Threatens Democracy. I saw her read at the Miami Book Fair several months ago, and immediately bought a copy. I even got her to sign it which is kinda cool ;) Cathy’s big idea is that we’re absolutely surrounded by algorithms that inform big decision making. There are lots of good algorithms that help us. Sadly, there are lots of insidiously, dangerous, bad algorithms that do serious damage, and they are lurking all about disguised as good algorithms. One aspect of a good algorithm is some kind of feedback and correctional… Read More

Continue Reading
stroke-gif

Text Stroke: Stuck In The Middle With You

There is a non-standard way to stroke HTML text (SVG has a standard way). It’s not particularly new. There are -webkit- and -moz- prefixes for it. Jen Simmons recently posted about it, with an example: span { -moz-text-fill-color: #fde; -webkit-text-fill-color: #fde; -moz-text-stroke-color: #666; -webkit-text-stroke-color: #666; -moz-text-stroke-width: 2px; -webkit-text-stroke-width: 2px; } And she’s right: This CSS isn’t fully-baked or fully-supported. But it’s good enough to be used today, especially since it’s simply offering a visual enhancement. It’s not mission critical to making a website usable. I’d only perhaps add that if you were going to do something like add a stroke around white text, you could wrap it in a @supports… Read More

Continue Reading
HeroPatterns

Websites to Generate SVG Patterns

These aren’t particularly hard to web search for, but just in case you didn’t know they existed I figured I’d drop them here. I’ve used all three of these in the past and I think they do a good job of driving home how cool of patterns you can make in SVG with such little code. Hero Patterns A collection of repeatable SVG background patterns for you to use on your web projects. SVG Patterns Gallery SVG images are typically smaller than bitmap images and remain sharp on high-dpi screens. Unlike CSS3 gradients, SVG images are supported on IE9. SVGeneration Scalable Vector Graphics are crisp and clear and can be… Read More

Continue Reading
illustrator

Tools to Visualize and Edit SVG Paths (Kinda!)

It was brought up at the SVG Summit the other day, wouldn’t it be nice when working with SVG to be able to work with it both ways at once? See and edit the code, and see the results visually See and edit the visual shapes, and see the code change There might not be the perfect one true tool, but there are certainly some ideas getting there! Anthony Dugois’s SVG Path Builder I’d embed the Pen here, but you really need a bit more space to play with it. Here’s a video of how it works: It shows you the code output, but you can’t adjust the code to… Read More

Continue Reading
Sales-process-overview

PHP For Beginners: Building a Simple CRM from Scratch

Customer Relationship Management (CRM) is a system that manages customer interactions and data throughout the customer lifecycle between the customer and the company across different channels. In this tutorial, we are going to build a custom CRM in PHP, which a sales team can use to track customers through the entire sales cycle. We’ll be creating a simple CRM system for salespeople to: Access their tasks View their leads Create new tasks for each lead Create new opportunity Lose a sale Sales managers will be able to: Manage all customers Manage sales team View current sales activities Download Demo Files Building Blocks of a CRM Here is a list of… Read More

Continue Reading