Friday, April 26

Tag: css

CSS Tricks

Empower Through Web Development

As a person with a disability, I appreciate the web and modern-day computing for their many affordances. The web is a great place to work and share and connect. You can make a living, build your dream, and speak your mind. It’s not easy, though. Beginners struggling with the box model often take to Google in search of guidance (and end up at this very website). More seasoned developers find themselves hopping from framework to framework trying to keep up. We experience plenty of late nights, console logs, and rage quits. It’s in times like these that I like to remember why I’m doing this thing. And that’s because of the magic of creating. Making websites is empowering because it allows you to shape the world—in ways big and small, public and personal. It’s especially powerful for people w...
CSS Tricks

Free E-book: ​Modernize for Mobile Apps

(This is a sponsored post.)No sign up required to read the free e-book. Building modern apps (mobile, PWAs or Single Page Apps) that connect to legacy or enterprise systems is a pain. We put together an e-book that discusses the various options for how to make it all work. Here are some of the chapter contents: The Challenges of Migrating to a Modern Mobile Architecture Strategies for Migrating to Mobile Strategies for Migrating to the Cloud Data & Mobile Applications Future-Proofing Your Modernization Efforts Check out our Mobile Modernization: Architect Playbook Direct Link to Article — PermalinkThe post Free E-book: ​Modernize for Mobile Apps appeared first on CSS-Tricks. Source: CSS-tricks.com
Vue + TypeScript: A Match Made in Your Code Editor
CSS Tricks

Vue + TypeScript: A Match Made in Your Code Editor

Vue is so hot right now and I’ve been thinking of doing a serious project with it since quite a while, so when the opportunity popped up, I hopped in. But there was a little problem — one of the requirements of the project was to write it in TypeScript. At first, I was super stressed about how I was going to ever get started on this combo, but vue-cli made it so easy. I’d be lying if I said this ride was super smooth. There were frustrations, hours of staring at the screen and some fistbumps with my table but after working with Vue + TypeScript for over a month now, I can say it was worth it — and if I had to code another app with Vue, I wouldn’t do it without TypeScript. Prerequisites This article is about pairing Vue and TypeScript and assumes some basic knowledge of both. If you haven’...
CSS Tricks

Better rendering for variable fonts

I was messing around with a variable font the other day and noticed this weird rendering issue in the latest version of Chrome where certain parts of letterforms were clipping into each other in a really weird way. Thankfully, though, Stephen Nixon has come to the rescue with a temporary hack to fix the issue which using a text-shadow on the text that’s using the variable font: .variable-font { text-shadow: 0 0 0 #000; /* text color goes last here */ } Once you do that, you shouldn’t be able to see those weird clip marks in the letterforms anymore. Yeah, it feels pretty hacky but I’m sure this rendering bug will be fixed relatively soon. It doesn’t look like it affects other browsers, as far as I can tell. Direct Link to Article — PermalinkThe post Better rendering for variable fonts ap...
Handling Errors with Error Boundary
CSS Tricks

Handling Errors with Error Boundary

Thinking and building in React involves approaching application design in chunks, or components. Each part of your application that performs an action can and should be treated as a component. In fact, React is component-based and, as Tomas Eglinkas recently wrote, we should leverage that concept and err on the side of splitting any large chunking into smaller components. Splitting inevitably introduces component hierarchies, which are good because they bloated components and architecture. However, things can begin to get complicated when an error occurs in a child component. What happens when the whole application crashes?! Seriously, React, why do the parent and sibling components have to pay for the sins of another component? Why? Error Boundaries React 16 came with a lot of goodies, o...
CSS Tricks

​Add real-time comments to a Gatsby blog

(This is a sponsored post.)This tutorial will show you how to add realtime comments to a Gatsby blog. You will use Node and Express to create a simple backend, allowing users to add and view comments instantly. Direct Link to Article — PermalinkThe post ​Add real-time comments to a Gatsby blog appeared first on CSS-Tricks. Source: CSS-tricks.com
CSS Tricks

Resilient, Declarative, Contextual

Keith J. Grant: I want to look at three key characteristics of CSS that set it apart from conventional programming languages: it’s resilient; it’s declarative; and it’s contextual. Understanding these aspects of the language, I think, is key to becoming proficient in CSS. Like HTML, unknown or slightly broken CSS doesn't stop a site in its tracks. You write something you want to happen in CSS, it happens, and a bunch of related things may happen to. I like Keith's example with font-size. Increase it, and the container will also grow in height without you having to tell it to. You can't understand what CSS is going to do without understanding the DOM structure it is paired with and the other styles at play. And it’s my suspicion that developers who embrace these things, and have fully inter...
Drawing Images with CSS Gradients
CSS Tricks

Drawing Images with CSS Gradients

What I mean by "CSS images" is images that are created using only HTML elements and CSS. They look as if they were SVGs drawn in Adobe Illustrator but they were made right in the browser. Some techniques I’ve seen used are tinkering with border radii, box shadows, and sometimes clip-path. You can find a lot of great examples if you search daily css images" on CodePen. I drew some myself, including this Infinity Gauntlet, but in one element with only backgrounds and minimal use of other properties. Let’s take a look at how you can create CSS images that way yourself. The Method Understanding the shorthand background syntax as well as how CSS gradients work is practically all you need to draw anything in one element. As a review, the arguments are as follows: background: <'background-co...
CSS Tricks

Users DO Change Font Size

Evan Minto: The question was “How many users browse the main Internet Archive site with a default font size other than the common value of 16 pixels?” By knowing this, we would determine how many users would be affected by sizing with relative units like rems/ems. Using the methodology I describe below, we found that the answer is 3.08% of our users. So if you set type in pixels, and your traffic is anything like the Internet Archive's, 3% of your users won't have their explicitly-asked-for font-size alteration accommodated. It's true. I made two little reduced test cases. First I left the default medium font-size preference on and set one with pixels and one with ems and sized them to match. Then bumped up the preference to large, and only the ems changed, the pixel-set one stays the s...
CSS Tricks

Animate Calligraphy with SVG

From time to time at Stackoverflow, the question pops up whether there is an equivalent to the stroke-dashoffset technique for animating the SVG stroke that works for the fill attribute. But upon closer inspection, what the questions are really trying to ask is something like this: I have something that is sort of a line, but because it has varying brush widths, in SVG it is defined as the fill of a path. How can this "brush" be animated? In short: How do you animate calligraphy? A mask path covers the calligraphic brushThe basic technique for this is relatively simple: draw a second (smooth) path on top of the calligraphy so that it follows the brush line and then choose the stroke width in such a way that it covers the calligraphy everywhere. This path on top will be used as a mask fo...
Balancing Time
CSS Tricks

Balancing Time

I first wrote this post four years ago. I put it on a blog that no longer exists. Funnily enough, I still refer to it myself, so I figured it might be best served in a place where other people can see it. I've made only a few minor tweaks to the original content. A lot about how I work has changed, but most of these pieces have not. I work on many personal projects concurrently. I love doing this, as it keeps me in a constant mode of creation. At the same time, it can become a delicate balancing act. In order to keep everything moving forward, I have set up some guidelines for myself and I'm going to share them with you in this post. However, it's more important to understand what works best for you and consider the sage words of Thich Nhat Hahn: “Don’t follow someone else’s map.” What w...
Advanced Document Conversions with Filestack
CSS Tricks

Advanced Document Conversions with Filestack

You might know Filestack from being an incredible service to add file uploading, storage, and management to your own web apps. There is another thing Filestack can do for you: convert documents into different formats. For one thing, it can manipulate documents. Take images. Perhaps you would like to offer some image manipulation for your users uploaded images, like cropping and rotation. That's a common feature for apps that offer avatar uploading. With Filestack, you got it. It's great to be able to have that kind of functionality without having to build it yourself. You almost surely aren't in the avatar cropping business, you're in your own unique business that just happens to have users with avatars. I've said it before: But let's up the ante a little bit here. What if you need to ...
CSS Tricks

An Almost Ideal React Image Component

Yes, this is a React component, but regardless if you care about that part or not, the "ideal image component" part could be of interest. There is a lot to consider with how we put images on web pages these days. This deals with: Placeholder space (and then flexible responsive styles after loading) Low-quality placeholder images Responsive images syntax (srcset) Image formats (e.g. using WebP when you can) Click-to-load on bad network connections Better UX for loading errors, with translatable copy That's not even all of it. So much to think about with poor little <img>. I enjoyed Alejandro Sanchez's response: The readme file for this component is amazing to teach you how to think like a front-end developer. — Alejandro Sanchez (@alesanchezr) June 12, 2018 Direct Link to Article — P...
CSS Tricks

Using Custom Fonts With SVG in an Image Tag

When we produce a PNG image, we use an <img> tag or a CSS background, and that's about it. It is dead simple and guaranteed to work. PNG is way simpler to use in HTML than SVGUnfortunately, the same cannot be said for SVG, despite its many advantages. Although you're spoiled for choices when using SVG in HTML, it really boils down to inline, <object> and <img>, all with serious gotchas and trade-offs. Problems with inline SVG If you're inlining SVG, you lose the ability to use browser cache, Gzip compression between servers and browsers, and search engine image indexing (inline SVG is not considered as an image). Even though your image may not have changed one bit, they are always reloaded and this causes slower loading times for your website, a trade-off that most are n...
What is SVG good for?
CSS Tricks

What is SVG good for?

Y'all probably wouldn't be surprised if I told you it's pretty awesome for icons, and icon systems. SVG icon systems can, and perhaps should be quite easy. I'm a fan of just inlining those suckers, particularly when they are pretty simple. But what else? Logos is a classic example! A lot of people dip their toes in this way. You don't have to inline the SVG if you don't want. It could be an <img> or background-image as well. These are really simple things though. At it's heart, SVG is simply a vector-based image format capable of just about anything. Way higher up the complexity scale, Bustle creates incredibly cool flowcharts using SVG. Try clicking around those flowcharts and seeing all the wonderful animation. SVG is very flexibly scalable. In that example above, part of what ...