Search
Holy Albatross with Widths
24.7.2020
Heydon’s Holy Albatross is a technique to have a row of elements break into a column of elements at a specific width. A specified parent width, not a screen width like a media query would have. So, like a container query (ya know, those things that don’t exist yet that we...
Using Flexbox and text ellipsis together
22.7.2020
You can truncate a single line of text with an ellipsis (…) fairly easily with text-overflow and a few friends. But, as you might expect, that truncation happens at the end of the line of text. What if you want to truncate content in the middle?
Leonardo Faria details good use cases for this...
Posters! (for CSS Flexbox and CSS Grid)
6.7.2020
Any time I chat with a fellow web person and CSS-Tricks comes up in conversation, there is a good chance they’ll say: oh yeah, that guide on CSS flexbox, I use that all the time!
Indeed that page, and it’s cousin the CSS grid guide, are among our top trafficked pages. I try to take...
Grid for layout, flexbox for components
26.6.2020
When should we reach for CSS grid and when should we use flexbox? Rachel Andrew wrote about this very conundrum way back in 2016:
Flexbox is essentially for laying out items in a single dimension – in a row OR a column. Grid is for layout of items in two dimensions – rows AND columns.
Ahmad...
Flexbox-like “just put elements in a row” with CSS grid
21.5.2020
It occurred to me while we were talking about flexbox and gap that one reason we sometimes reach for flexbox is to chuck some boxes in a row and space them out a little.
My brain still reaches for flexbox in that situation, and with gap, it probably will continue to do so. It’s worth noting...
Chromium lands Flexbox gap
9.5.2020
I mentioned this the other day via Michelle Barker’s coverage, but here I’ll link to the official announcement. The main thing is that we’ll be getting gap with flexbox, which means:
.flex-parent {
display: flex;
gap: 1rem;
}
.flex-child {
flex: 1;
}
That’s excellent...
Exciting Things on the Horizon For CSS Layout
8.5.2020
Michelle Barker notes that it’s been a heck of a week for us CSS layout nerds.
Firefox has long had the best DevTools for CSS Grid, but Chrome is about to catch up and go one bit better by visualizing grid line numbers and names.
Firefox supports gap for display: flex, which is great,...
Thinking in Behaviors, Not Screen Sizes
11.4.2020
Chase McCoy wrote a nifty post about the “gap problem” when making a grid of items. His argument might be summarized like this: how should we space elements with margins in CSS? He notes that the gap property isn’t quite ready for prime time when it comes to using it with flexbox, like this:
.grid...
Flexbox and absolute positioning
18.3.2020
Chen Hui Jing notes that when you absolutely position a flex item, it's no longer part of the flex layout. Except... it kinda is a little bit. If you make the child position: absolute; but don't apply any top/right/bottom/left properties, then flexbox alignment will still apply to it.
It's odd...
monica.css
20.2.2020
Monica Dinculescu:
I don’t want every possible padding and margin and colour and flexbox configuration in the world. I just want the ones that I know I end up using in every project. So here is monica.css: my very own CSS framework, which I copy paste at the beginning of every CSS file and take...
Four Layouts for the Price of One
29.1.2020
Pretty notable when a tweet about a flexbox layouts gets 8K+ likes on Twitter!
4 layouts for the price of 1, thanks flex ????
css` form { display: flex; flex-wrap: wrap;
& > input { flex: 1 1 10ch; margin: .5rem;
&[type="email"] { flex: 3...
Flexible Captioned Slanted Images
25.1.2020
The end result of Eric Meyer's tutorial on creating this row of slanted images is pretty classy. But it's more about the journey than the destination (there isn't even really an isolated demo for it). Eric does an amazing job at talking it through like a thought process.
We did that recently, only...
CSS-Only Carousel
10.1.2020
It's kind of amazing how far HTML and CSS will take you when building a carousel/slideshow.
Setting some boxes in a horizontal row with flexbox is easy.
Showing only one box at a time with overflow and making it swipable with -webkit-overflow-scrolling is easy.
You can make the "slides" line...
How Auto Margins Work in Flexbox
6.1.2020
Robin has covered this before, but I've heard some confusion about it in the past few weeks and saw another person take a stab at explaining it, and I wanted to join the party.
Say you have a flex container with some flex items inside that don't fill the whole area.
See the Pen
ZEYLVEX...
Stream-Crossing Confusion
23.12.2019
Should I use WordPress or React hooks?
Should I use D3 or CSS?
Should I use Markdown or JSON?
Can I use flexbox in Gatsby?
Can I use custom properties in Jekyll?
Should I use HTML or the cloud?
How do I add dark mode to my Vue site?
These are tongue-in-cheek, but there is a point to be made here....
Adam Argyle’s 2020 CSS Predictions
13.12.2019
I think Adam's first prediction is his boldest, even beyond his Hail Mary prediction. CSS grid is awesome and gap is perhaps one of its best qualities, but gap superseding spacing things out in other ways (e.g. margin) is a bold prediction indeed, especially with Firefox being the only browser...
The Thought Process Behind a Flexbox Layout
27.11.2019
I just need to put two boxes side-by-side and I hear flexbox is good at stuff like that.
Just adding display: flex; to the parent element lays out the children in a row.
Well, that's cool. I guess I could have floated them, but this is easier.
They should probably take up the full space they have...
Making Tables Responsive With Minimal CSS
17.10.2019
Here’s a fabulous CSS trick from Bradley Taunt in which he shows how to make tables work on mobile with just a little bit of extra code. He styles each table row into a card that looks something like this:
See the Pen
Responsive Tables #2.5: Flexbox by Bradley Taunt (@bradleytaunt)
...
Collective #555
7.10.2019
Guided by style * Adaptive Photo Layout with Flexbox * Screen Size Map * Raw WebAssembly Demos * Imagededup
Collective #555 was written by Pedro Botelho and published on Codrops
Adaptive Photo Layout with Flexbox
3.10.2019
Let’s take a look at a super lightweight way to create a horizontal masonry effect for a set of arbitrarily-sized photos. Throw any set of photos at it, and they will line up edge-to-edge with no gaps anywhere.
The solution is not only lightweight but also quite simple. We’ll be using an unordered...