Thursday, November 21

Tag: css

XOXO 2018
CSS Tricks

XOXO 2018

There’s not much talk about frameworks here. There’s no shaming about old techniques, or jokes about JavaScript. There’s just a couple hundred people all around me laughing and smiling and watching talks about making things on the web and it all feels so fresh and new to me. Unlike many other conferences I’ve visited, these talks are somehow inclusive and rather feel, well, there’s no other word for it: inspiring. I’m sitting in a little room buried underneath the Veterans Memorial Coliseum in Portland and I’m here for my third XOXO. And I can’t stop smiling. Although the festival is not entirely focused on coding and front-end development, there are a lot of developers here that make art on the web for fun. From Jenn Schiffer’s pixel art to Monica Dinculescu’s emoji projects and Nicole He...
CSS Tricks

What’s the difference between ./dogs.html and /dogs.html?

They are both URL paths. They have different names, though. <!-- root-relative --> <a href="./dogs.html">Dogs</a> <!-- absolute --> <a href="/dogs.html">Dogs</a> There are also fully-qualified URLs that would be like: <!-- fully qualified --> <a href="https://website.com/dogs.html">Dogs</a> Fully-qualified URL's are pretty obvious in what they do — that link takes you to that exact place. So, let's look those first two examples again. Say you have a directory structure like this on your site: public/ ├── index.html └── animals/ ├── cats.html └── dogs.html If you put a link on cats.html that links to /dogs.html (an "absolute" path), it's going to 404 — there is no dogs.html at the base/root level of this site! The / at the beg...
CSS Tricks

Visual. Intuitive. Unlike Anything Else.

(This is a sponsored post.)This team management tool is exceptionally suitable for any industry sector and by any sized team. monday.com will perfectly serve a team of two or a team of hundreds spread around the globe, and it can manage multiple projects at once. monday.com promotes effortless collaboration and transparency, it's "cheetah fast," it displays status in as many as 20 different colors, and its status board can be customized to fit your needs and your workflow. It serves as an excellent alternative to having to force fit your work to meet the demands of your project management tools or systems. Start Free Trial Direct Link to Article — PermalinkThe post Visual. Intuitive. Unlike Anything Else. appeared first on CSS-Tricks. Source: CSS-tricks.com
CSS Tricks

Updating a CSS Variable with JavaScript

Here's a CSS variable (formally called a "CSS custom property"): :root { --mouse-x: 0px; --mouse-y: 0px; } Perhaps you use them to set a position: .mover { left: var(--mouse-x); top: var(--mouse-y); } To update those values from JavaScript, you'd: let root = document.documentElement; root.addEventListener("mousemove", e => { root.style.setProperty('--mouse-x', e.clientX + "px"); root.style.setProperty('--mouse-y', e.clientY + "px"); }); That's all. Source: CSS-tricks.com
CSS Tricks

Introducing Trashy.css

Trashy.css: The throwaway CSS library with no class   Why throwaway? Well, it's not really meant to be a fully fledged, production-ready style framework. Rather, it's like training wheels for document semantics, with some bumper lanes (think: bowling) to keep you on the right track. It's part of our ongoing effort at TandemSeven to promote code literacy throughout our organization. As more of our UX designers are beginning to share responsibility for the accessibility and semantics of a project, it makes sense that we would build in such a way that allows UX and development to be more collaborative. There are four main aspects to Trashy. Trashy: "Basic" First is the base trashy.css file, which applies a passably basic look and feel to the majority of common HTML elements...
CSS Tricks

The Low Hanging Fruit of Web Performance

I kicked off a really poppin' Twitter thread the other day: What are the LOWEST hanging fruit of web performance? Nothing fancy, anyone can do, big impact. Gzip. Optimize stuff. Reduce requests... What are other big ones? — Chris Coyier (@chriscoyier) August 17, 2018 So, I decided to round up all the ideas (both my own and yours) around that in a post over on the Media Temple blog. These are the things we dive into in that post: Reduce Requests Optimize Assets Make sure you’re gzipping Make sure you’re browser caching Use a CDN Lazy Load and Defer Loading of Things Use responsive images (or at least use reasonable sizes) Mind Your Fonts Good Hosting / HTTP2 / PHP7 Turbolinks Direct Link to Article — PermalinkThe post The Low Hanging Fruit of Web Performance appeared first on CSS-Tricks...
CSS Tricks

Changes on CSS Grid Layout in percentages and indefinite height

This is a wonderfully nerdy deep dive into a very specific CSS change by Manuel Rego Casasnovas. Here's a bit of terminology we should know: First question is, what is an indefinite size? The simple answer is that a definite size is a size that you can calculate without taking into account the contents of the element. An indefinite size is the opposite, in order to compute it you need to check the contents first. And then goes on to explain how complicated this all gets. The change, in a nutshell: Percentages row tracks and gutters for indefinite height grid containers will be resolved against the intrinsic height instead of being treated as auto and zero respectively. Manuel provides a nice visual demo: See the Pen [css-grid] Percentage row tracks by Manuel Rego Casasnovas (@mrego) on Co...
Old Timey Terminal Styling
CSS Tricks

Old Timey Terminal Styling

I saw a little demo the other day called HTML5 Terminal. It has some functionality, but it seems like it's just kinda for fun. That said, I loved the aesthetic of it! Blurry monospace type with visible monitor lines and a glowing green background — nice! Let's re-create that, bit-by-bit. A radial gradient is perfect for the glowing green background: body { background-color: black; background-image: radial-gradient( rgba(0, 150, 0, 0.75), black 120% ); height: 100vh; } I'm so used to using <pre><code> to display space-formatted text (like code), but you could say terminal text isn't always code, so I like the use of <pre><output> here. Might as well use a nice monospace font: body { ... color: white; font: 1.3rem Inconsolata, monospace; } The text ...
Jetpack’s Social Integration Features
CSS Tricks

Jetpack’s Social Integration Features

One of the many things we use Jetpack for here on CSS-Tricks is all of its features related to social media integration. For example, Jetpack can automatically share published content to different social media accounts simultaneously, add sharing buttons to your site's theme, and allow for social login on the comment form. There is even more than that, but let's dig into these three as we use them. Auto-Sharing Posts I like the idea that everything we published goes out to social media. Many people only follow the site that way, so they should see what we're writing. We're specifically into Twitter and Facebook. With Jetpack installed connected to WordPress.com, I can now flip on the setting: Then authenticate the services you want to connect: Now as we publish new articles, there are Pub...
CSS Tricks

Customise radio buttons without compromising accessibility

Here’s a nifty post by Chen Hui Jing where she walks us through her process for making radio buttons accessible via keyboard. I particularly enjoyed this bit where she discusses the four options that are available to us to hide the radio input and replace them with a selection of cards that act like toggles instead: Most of us mess up the keyboard navigation portion of things when we hide the input element. There are several ways to make something invisible or hidden: clip-path: polygon(0 0) display: none opacity: 0 visibility: hidden For custom radios (or checkboxes), option 2 and 4 are not recommended because screen readers won’t be able to read the default radio element. This also prevents us from using the :focus pseudo-element on the hidden input, so those are out of the picture. Whi...
Creating sliding effects using sticky positioning
CSS Tricks

Creating sliding effects using sticky positioning

Sticky elements are predominantly used for keeping something shown on the screen throughout scrolling. As cool as that is, we can also hide elements in the same way! Here’s a typical (um) sticky situation: See the Pen position:sticky (CSS) by Preethi Sam (@rpsthecoder) on CodePen. Sticky elements (position: sticky;) are very similar to fixed elements ( position: fixed;) in that they both maintain their position on the screen, even as the user scrolls up or down the page. The difference? A sticky element remains confined to the parent container it is in. Compare sticky example above with this one that uses the same concept using a fixed element instead: See the Pen position:sticky (CSS) by CSS-Tricks (@css-tricks) on CodePen. Say we want to create an effect where elements either slide in o...
CSS Tricks

Interactive Introduction to CSS Houdini

This is a great explanatory microsite by Sam Richard. CSS Houdini will let authors tap in to the actual CSS engine, finally allowing us to extend CSS, and do so at CSS speeds. Much like Service Workers are a low-level JavaScript API for the browser's cache, Houdini introduces low-level JavaScript APIs for the browser's render engines. What's important to know is that Houdini is broken up into these different parts, each of which will be implemented separately. We have an intro to the paint API here and a number of other articles that touch on it. Here's a very cool collection Dan Wilson put together of Houdini + Custom Properties. Direct Link to Article — PermalinkThe post Interactive Introduction to CSS Houdini appeared first on CSS-Tricks. Source: CSS-tricks.com
“Killing the URL”
CSS Tricks

“Killing the URL”

It was Safari who first started hiding the complete URL. Here's what CSS-Tricks looks like even when you're on an article page by default in Safari: The full URL path is hidden.You can only fix it (YES, FIX IT) by checking "Show full website address" in settings. Preferences > AdvancedWe've already damaged the sanctity of URLs in a way with URL shorteners. Thankfully, those are used less and less with social networks, like Twitter, not counting the URL toward the total tweet character count anymore. Now, Lily Hay Newman reports Chrome sees problems as well: "People have a really hard time understanding URLs," says Adrienne Porter Felt, Chrome's engineering manager. "They’re hard to read, it’s hard to know which part of them is supposed to be trusted, and in general I don’t think URLs a...
CSS Tricks

Shadow DOM in Ionic

Mike Hartington glows about how good and useful the Shadow DOM is: [Shadow DOM is] actually built on two simple ideas, isolation and location. Need to create a bit of DOM that is isolated from the global scope? Shadow DOM is here to help. Need to specify the exact location of a piece of DOM? Shadow DOMs scope API is what you need! It can be helpful to think of components that use Shadow DOM as modules for HTML. Markup and styles are isolated to their own DOM tree, and removed from the global context. Last time we talked about it around here, I showed how Twitter is using it for embedded tweets — which is a pretty awesome use case — and how it can fall back to an iframe. Mike says they polyfill it in unsupported situations. I suspect isolated styles is the primary selling point for any o...
CSS Tricks

Working With Events in React

Most of the behavior in an application revolves around events. User enters a value in the registration form? Event. User hits the submit button? Another event. Events are triggered a number of ways and we build applications to listen for them in order to do something else in response. You may already be super comfortable working with events based on your existing JavaScript experience. However, React has a distinct way of handling them. Rather than directly targeting DOM events, React wraps them in their own event wrapper. But we’ll get into that. Let’s go over how to create, add and listen for events in React. Creating Events We’ll start by creating a form that has an input and a button. An event will be triggered when a value is entered. The button is used to call a function which will ...