Post pobrano z: Billie![]()
Archiwum kategorii: CSS
Drip
Post pobrano z: Drip![]()
V6: Typography and Proportions
Post pobrano z: V6: Typography and Proportions
Here’s a good ol’ fashion blog post by Rob Weychert where he looks into the new design system that he implemented on his personal website and specifically the typographic system that ties everything together:
According to the OED, a scale is “a graduated range of values forming a standard system for measuring or grading something.” A piece of music using a particular scale—a limited selection of notes with a shared mathematic relationship—can effect a certain emotional tenor. Want to write a sad song? Use a minor scale. Changed your mind? Switch to a major scale and suddenly that same song is in a much better mood.
Spatial relationships can likewise achieve a certain visual harmony using similar principles, and the constraints a scale provides take a lot of the arbitrary guesswork out of the process of arranging elements in space. Most of what I design that incorporates type has a typographic scale as its foundation, which informs the typeface choices and layout proportions. The process of creating that scale begins by asking what the type needs to do, and what role contrasting sizes will play in that.
Direct Link to Article — Permalink
V6: Typography and Proportions is a post from CSS-Tricks
An Idea for a Simple Responsive Spreadsheet
Post pobrano z: An Idea for a Simple Responsive Spreadsheet
How do you make a spreadsheet-like interface responsive without the use of any JavaScript? This is the question I’ve been asking myself all week as I’ve been working on a new project and trying to figure out how to make the simplest spreadsheet possible. I wanted to avoid using a framework and instead, I decided to experiment with some new properties in order to use nothing but a light touch of CSS.
Spoilers! This is what I’ve come up with so far (oh and please note that this demo currently works in the latest version of Chrome). Try scrolling around a little bit:
See the Pen A Simple Responsive Spreadsheet – Final by Robin Rendle (@robinrendle) on CodePen.
Notice how the first column sticks to the left and the heading sticks to the top of the spreadsheet? This lets us scan lots of data without having to keep scrolling to figure out which column or row we’re in — in a lot of interfaces like this it’s pretty easy to get lost.
So how did I go about making this thing? Let’s jump in!
Adding the markup
First we need to add our markup for the table and, just to make sure that this example is as realistic as possible, we’re going to add a lot of rows and columns here:
See the Pen A Simple Responsive Spreadsheet – 1st by Robin Rendle (@robinrendle) on CodePen.
There’s nothing really complex going on. We just have a regular ol’ table with a <thead> and a <tbody>, but we do wrap the whole table in the table-wrapper div which I’ll explain in just a little bit.
Next, we’ll add basic styling to that wrapper element to move it into the center of the page and also give it a max-width. We also need to make sure that the .table-wrapper has overflow set to scroll, although at larger screen sizes we won’t need that just yet:
body {
display: flex;
font-family: -apple-system;
font-size: 90%;
color: #333;
justify-content: center;
}
.table-wrapper {
max-width: 700px;
overflow: scroll;
}
See the Pen A Simple Responsive Spreadsheet – 2nd by Robin Rendle (@robinrendle) on CodePen.
Nifty! Now we can add styles for the first column of our table and the thead element as well as basic styling for each of the table cells:
table {
border: 1px solid #ddd;
border-collapse: collapse;
}
td, th {
white-space: nowrap;
border: 1px solid #ddd;
padding: 20px;
}
See the Pen A Simple Responsive Spreadsheet – 3 by Robin Rendle (@robinrendle) on CodePen.
The problem here is that we’ve now made a pretty inaccessible table; although we can scroll around in the spreadsheet we can’t read which column or row is associated to which bit of data. This can lead to a table that is almost completely illegible and if we were to populate this with real data then it would be even worse:

position: sticky to the rescue!
position: sticky is a wonderfully handy CSS trick that I’ve started experimenting with a great deal lately. It lets you stick child elements to their parent containers so that as you scroll around the child element is always visible. And this is exactly what we need here for the first column and the heading of our table element.
We can use this relatively new feature with CSS like this:
// The heading of our table
th {
background-color: #eee;
position: sticky;
top: -1px;
z-index: 2;
// The first cell that lives in the top left of our spreadsheet
&:first-of-type {
left: 0;
z-index: 3;
}
}
// The first column that we want to stick to the left
tbody tr td:first-of-type {
background-color: #eee;
position: sticky;
left: -1px;
z-index: 1;
}
This z-index values are important here because we want the header to overlap the first left hand column that will also be sticky. However! We also want that empty cell at the top left to overlap both our header and our left hand column, like this:
See the Pen A Simple Responsive Spreadsheet – Final by Robin Rendle (@robinrendle) on CodePen.
But there we have it! A simple responsive spreadsheet where you can view both the heading and the first column no matter where you are in the table. Although, it’s worth noting that your mileage may vary. position: sticky has relatively patchy support right now and so it’s worth thoroughly testing before you start using it. Or you could use something like Stickybits that would act as a lightweight polyfill.
Also, if you need to dig into tables in more depth then we’ve made a rather handy Complete Guide to the Table Element.
An Idea for a Simple Responsive Spreadsheet is a post from CSS-Tricks
Introducing minmax()
Post pobrano z: Introducing minmax()
It’s relatively easy to get lost in all the new features of CSS Grid because there’s just so much to learn and familiarize ourselves with; it’s much easier to learn it chunk by chunk in my opinion.
And so you might already be familiar with Rachel Andrew’s Grid By Example which contains a whole bunch of tutorials with new layout tips and tricks about CSS Grid. But the minmax() tutorial is one small chunk of Grid that you can learn today and thankfully Rachel has made a rather handy two minute long video that dives straight into it.
In fact, it’s pretty darn impressive how many opportunities just one new CSS feature can give us.
Direct Link to Article — Permalink
Introducing minmax() is a post from CSS-Tricks
Happier HTML5 Form Validation
Post pobrano z: Happier HTML5 Form Validation
HTML has given us loads of form validation stuff in the last few years. Dave Rupert puts a point on the UX problems with it:
If you’ve ever experimented with HTML5 Form Validation, you’ve probably been disappointed. The out-of-box experience isn’t quite what you want. Adding the
requiredattribute to inputs works wonderfully. However the styling portion withinput:invalidsorta sucks because empty inputs are trigger the:invalidstate, even before the user has interacted with the page.
Fortunately, there is an invalid DOM event that does fire with useful timing: when the form is submitted. Remember this doesn’t buy you super deep browser support though. If you need that, look into polyfilling. I imagine the future of form validation is either HTML/CSS offering better and more controllable UX, or this.
Direct Link to Article — Permalink
Happier HTML5 Form Validation is a post from CSS-Tricks
Airplanes and Ashtrays
Post pobrano z: Airplanes and Ashtrays
Harry Roberts wrote about design systems and how compromise has to be baked into them from the very start. He argues that we can’t be dictatorial about what is and isn’t permitted because design, whether that’s the design of a product, service or system, is always about compromise.
Harry writes:
Whenever you plan or design a system, you need to build in your own ashtrays—a codified way of dealing with the inevitability of somebody doing the wrong thing. Think of what your ideal scenario is—how do you want people to use whatever you’re building—and then try to identify any aspects of it which may be overly opinionated, prescriptive, or restrictive. Then try to preempt how people might try to avoid or circumvent these rules, and work back from there until you can design a safe middle-ground into your framework that can accept these deviations in the safest, least destructive way possible.
Direct Link to Article — Permalink
Airplanes and Ashtrays is a post from CSS-Tricks
Styleable
Post pobrano z: Styleable
The Wix dev team throws their hat into the CSS preprocessor ring:
Stylable is a CSS preprocessor that enables you to write reusable, highly-performant, styled components. Each component exposes a style API that maps its internal parts so you can reuse components across teams without sacrificing stylability.
- Scopes styles to components so they don’t “leak” and clash with other styles.
- Enables custom pseudo-classes and pseudo-elements that abstract the internal structure of a component. These can then be styled externally.
- Uses themes so you can apply different look and feel across your web application.
At build time, the preprocessor converts the Stylable CSS into flat, static, valid, vanilla CSS that works cross-browser.
Looks like Sass luminary Chris Eppstein is getting in on the game of scoped styles with the not-yet-released CSS Blocks. And think of Vue’s support for <style scoped>, and the popularity of utility libraries. I think scoped styles might be the hottest CSS topic in 2018.
Direct Link to Article — Permalink
Styleable is a post from CSS-Tricks
One Simple Action
Post pobrano z: One Simple Action![]()
Zeus Jones
Post pobrano z: Zeus Jones![]()