Thursday, March 28

Tag: css

CSS Tricks

UTC is Enough for Everyone, Right?

A good candidate for the Blog Post of the Year from Zach Holman. I think Eric Portis' "w descriptors and sizes: Under the hood" is up there too, but perhaps even nerdier. Ooooh, also Frank Chimero's "The Good Room" is up there. But I digress. Zach's article is as educational as it is funny. But yeah, this UTC initialism doesn’t make any sense. Let’s dig into this a little more. So you’ve got a bunch of scientist types around 1960 who are like, hey, time is all screwy we should totes make a standard. And some of them spoke English, and some of them spoke French, which, of course, is the cause of so much conflict over so many generations. (In hindsight, maybe we should have split all those troublemakers up from the start.) The English-speaking folk were like yo, this definitely sounds like...
Centering: The Newest Coolest Way vs. The Oldest Coolest Way
CSS Tricks

Centering: The Newest Coolest Way vs. The Oldest Coolest Way

This isn't a comprehensive guide to centering things. We have that! This is just a little observation about old and new. One of the trickier things related to centering in CSS is when you need to center both vertically and horizontally and you don't know the width or height of what you are centering. Vertical centering being the extra tricky of the two. Believe it or not, there was a way to do that even in IE 8. (more…)
Don’t just copy the @font-face out of Google Fonts URLs
CSS Tricks

Don’t just copy the @font-face out of Google Fonts URLs

I don't think this is an epidemic or anything, but I've seen it done a few times and even advocated for. This is what I mean... You go to Google Fonts and pick a font like Open Sans, and it gives you either a <link> or an @import with a URL there in which to ready this font for usage on your site. You can take a peek in there and see what it returns... It's just some @font-face declarations, of course! Now your performance-minded brain kicks off. Wait. So, I make one HTTP request for this stylesheet, and then it makes more HTTP requests for those woff2 files it's linking up. Screw the middle man here, why not just copy those @font-face blocks right out of here and use them. You can! But! The issue is that Google does fancy Google things here and the contents of that original styles...
The Four Big Ways Jetpack Helps with Image Performance
CSS Tricks

The Four Big Ways Jetpack Helps with Image Performance

We've been working with Jetpack around here as a sponsor. It's a great match because as someone with a bunch of self-hosted WordPress sites, Jetpack is one of those no-brainer plugins for me. Jetpack can do a ton of good things for any site in a variety of very different ways. Here's one way to think about it: it brings the power of WordPress' own massive servers to you. For now, let's just focus on one angle of what Jetpack can do for you: image performance. Jetpack does a ton for you in this regard, solving some non-trivial performance upgrades. Let's take a look at what I see as the four big boosts you get from Jetpack on your images. 1) WordPress does responsive images for you OK, I cheated with the first one because you don't actually need Jetpack to benefit from this. But it's an i...
Building a RSS Viewer With Vue: Part 2
CSS Tricks

Building a RSS Viewer With Vue: Part 2

Welcome to Part 2 of this mini-series on building a RSS viewer with Vue. In the last post, I walked through how I built my demo using Vue.js and Vuetify on the front end and Webtask on the back end. When I built that initial version, I knew it was exactly thatmdash;an "initial" version. I took some time to work on a few updates, and while I won't dare call this a "perfect" version, I do think I've made some improvements and I'd like to share them with you. Article Series: Setup and first iteration Refinements and final version (This Post) Before I get started, here are links to the completed demo and source code. View Demo View Code Feel free to fork, file PRs, and report bugs to your heart's content! The Plan When I shared the initial version in Part 1, I outlined some ideas to imp...
CSS Tricks

Here’s the thing about “unused CSS” tools

There are a lot of tools that aim to help you remove "unused CSS" from your project. Never a week goes by that I don't see a tool for this being shared or promoted. It must strike some kind of perfect chord for some developers. I care about performance, and I know that reducing file sizes is good for performance. Indeed, it is. I bet we have CSS that is unused in our stylesheets, if we removed that, that's a performance win. Yep, it would be. We should automate that. Ehhhhhh, I'm not so sure. There are major performance tooling players that play up this idea, like Lighthouse and how it gives you CSS and JS "Coverage", which will surely tell you that you're shipping code you don't need to be. The tools that claim to help you with unused CSS have to perform analysis to be able to tell you w...
Building a RSS Viewer With Vue: Part 1
CSS Tricks

Building a RSS Viewer With Vue: Part 1

As I explore, learn, and most importantly, play with Vue.js, I've been building different types of apps as a way to get practice with and improve my use of it. A few weeks ago, I was reading about the shut down of Digg's RSS Reader and while great alternatives exist, I thought it would be fun to build my own with Vue. In this article, I'm going to explain how I put it together and also what's wrong with it. I knew getting into this that I was going to make some compromises, so the plan is to follow up this version with a nicer one in a follow-up post. Article Series: Setup and first iteration (This Post) Refinements and final version (Coming Soon!) Let's start by looking at the app and explaining the various components. View DemoView Code A Look at the App When opening the applicatio...
Creating your own meme generator
CSS Tricks

Creating your own meme generator

Almost every time a new meme pops up in my Twitter feed, I think of a witty version to create. I'm not alone in this. Memes are often a way to acknowledge a shared experience or idea. In a variation of the "Is this a pigeon" meme that has been making the rounds online, a designer Daryl Ginn joked about the elementary nature of most applications that say they use artificial intelligence. pic.twitter.com/nAHki0YFyV — Daryl Ginn (@darylginn) May 16, 2018 Several people replied to his tweet saying something along the lines of "replace this with this." Daryl's version got them thinking about other possible variations. Platforms like imgFlip exist to make meme generations fast and easy. However, there is only so much customization they can allow. For many memes, creating new versions can only...
More Unicode Patterns
CSS Tricks

More Unicode Patterns

Creating is the most intense excitement one can come to know. —Anni Albers, On Designing I recently wrote a post — that was shared here on CSS-Tricks — where I looked at ways to use Unicode characters to create interesting (and random) patterns. Since then, I’ve continued to seek new characters to build new patterns. I even borrowed a book about Unicode from a local library. (That's a really thick book, by the way.) It's all up to your imagination to see the possible patterns a Unicode character can make. Although not all characters are good as patterns, the process is a good exercise for me. And, aside from Unicode itself, the methods to build the patterns may not be so obvious. It usually takes a lot of inspiration and trial and error to come up with new ones. More tiling There are ac...
CSS Tricks

​Truly understand your site visitors’ behavior

(This is a sponsored post.)Hotjar is a quick and easy way to truly understand your visitors and identify opportunities for improvement and growth. Try the all-in-one analytics and feedback tool for free. Direct Link to Article — PermalinkThe post ​Truly understand your site visitors’ behavior appeared first on CSS-Tricks. Source: CSS-tricks.com
Understanding the Almighty Reducer
CSS Tricks

Understanding the Almighty Reducer

I was recently mentoring someone who had trouble with the .reduce() method in JavaScript. Namely, how you get from this: const nums = [1, 2, 3] let value = 0 for (let i = 0; i < nums.length; i++) { value += nums[i] } ...to this: const nums = [1, 2, 3] const value = nums.reduce((ac, next) => ac + next, 0) They are functionally equivalent and they both sum up all the numbers in the array, but there is a bit of paradigm shift between them. Let's explore reducers for a moment because they're powerful, and important to have in your programming toolbox. There are literally hundreds of other articles on reducers out there, and I'll link up some of my favorites at the end. What is a reducer? The first and most important thing to understand about a reducer is that it will always only retu...
Your Brain on Front-End Development
CSS Tricks

Your Brain on Front-End Development

Part of the job of being a front-end developer is applying different techniques and technologies to pull of the desired UI and UX. Perhaps you work with a design team and implement their designs. I know when I look at a design (heck, even if I know I'm not going to be building it), my front-end brain starts triggering all sorts of things I know will be related to the task. Let's take a look at what I mean. Check out this lovely Dribbble shot for a Food Recipe Website from Riko Sapto Dimo. It's a very appealing design, and there is loads in there to think about from a front-end web design and development standpoint. We're going to mostly be talking about design pattern choices and HTML/CSS tech choices. There is much more to the job of front-end development. Accessibility! Performance! Se...
CSS Tricks

A Quick Roundup of Recent React Chatter

Like many, many others, I'm in the pool of leveling up my JavaScript skills and learning how to put React to use. That's why Brad Frost resonated with me when he posted My Struggle to Learn React." As Brad does, he clearly outlines his struggles point-by-point: I have invested enough time learning it React and ES6 travel together Syntax and conventions Getting lost in this-land I haven’t found sample projects or tutorials that match how i tend to work I'm less competent at JS than HTML and CSS It seems that Brad's struggles resonated with others as well, inspiring empathy and help from the community. For example, Kevin Ball touches on the second and third frustrations by supplying a distinction between React and ES6 and examples of the syntax and conventions of each: For each feature, I s...
Creating a Bar Graph with CSS Grid
CSS Tricks

Creating a Bar Graph with CSS Grid

If you’re looking for more manageable ways to create bar graphs, or in search of use cases to practice CSS Grid layout, I got you! Before we begin working on the graph, I want to talk about coding the bars, when Grid is a good approach for graphs, and we’ll also cover some code choices you might consider before getting started. Preface The bar is a pretty basic shape: you can control its dimensions with CSS width, height, number of grid or table cells, etc. depending on how you’ve coded it. As far as graphs go, the main thing we want to control is the height of the bars in the graph. Controlling height with Grid cells (like here) is convenient for designs where the height is incremental by a fixed value — no in-betweens. For example, signal bars in phones or when you don’t mind setting a ...
CSS Tricks

​​Build live comments with sentiment analysis using Nest.js

(This is a sponsored post.)Interestingly, one of the most important areas of a blog post is the comment section. This plays an important role in the success of a post or an article, as it allows proper interaction and participation from readers. This makes it inevitable for every platform with a direct comments system to handle it in realtime. In this post, we’ll build an application with a live comment feature. This will happen in realtime as we will tap into the infrastructure made available by Pusher Channels. We will also use the sentiment analysis to measure whether comments are positive or negative, and display this information on an admin panel. Direct Link to Article — PermalinkThe post ​​Build live comments with sentiment analysis using Nest.js appeared first on CSS-Tricks. ...