#css grid
Explore tagged Tumblr posts
hezacodes · 2 years ago
Text
Helpful Poster Guide from CSS-Tricks for CSS Grid
Tumblr media
172 notes · View notes
artmasiah · 1 month ago
Text
Tumblr media
Adding color to my website design⭐
6 notes · View notes
jcmarchi · 3 months ago
Text
Revisiting CSS Multi-Column Layout
New Post has been published on https://thedigitalinsider.com/revisiting-css-multi-column-layout/
Revisiting CSS Multi-Column Layout
Honestly, it’s difficult for me to come to terms with, but almost 20 years have passed since I wrote my first book, Transcending CSS. In it, I explained how and why to use what was the then-emerging Multi-Column Layout module.
Hint: I published an updated version, Transcending CSS Revisited, which is free to read online.
Perhaps because, before the web, I’d worked in print, I was over-excited at the prospect of dividing content into columns without needing extra markup purely there for presentation. I’ve used Multi-Column Layout regularly ever since. Yet, CSS Columns remains one of the most underused CSS layout tools. I wonder why that is?
Holes in the specification
For a long time, there were, and still are, plenty of holes in Multi-Column Layout. As Rachel Andrew — now a specification editor — noted in her article five years ago:
“The column boxes created when you use one of the column properties can’t be targeted. You can’t address them with JavaScript, nor can you style an individual box to give it a background colour or adjust the padding and margins. All of the column boxes will be the same size. The only thing you can do is add a rule between columns.”
She’s right. And that’s still true. You can’t style columns, for example, by alternating background colours using some sort of :nth-column() pseudo-class selector. You can add a column-rule between columns using border-style values like dashed, dotted, and solid, and who can forget those evergreen groove and ridge styles? But you can’t apply border-image values to a column-rule, which seems odd as they were introduced at roughly the same time. The Multi-Column Layout is imperfect, and there’s plenty I wish it could do in the future, but that doesn’t explain why most people ignore what it can do today.
Patchy browser implementation for a long time
Legacy browsers simply ignored the column properties they couldn’t process. But, when Multi-Column Layout was first launched, most designers and developers had yet to accept that websites needn’t look the same in every browser.
Early on, support for Multi-Column Layout was patchy. However, browsers caught up over time, and although there are still discrepancies — especially in controlling content breaks — Multi-Column Layout has now been implemented widely. Yet, for some reason, many designers and developers I speak to feel that CSS Columns remain broken. Yes, there’s plenty that browser makers should do to improve their implementations, but that shouldn’t prevent people from using the solid parts today.
Readability and usability with scrolling
Maybe the main reason designers and developers haven’t embraced Multi-Column Layout as they have CSS Grid and Flexbox isn’t in the specification or its implementation but in its usability. Rachel pointed this out in her article:
“One reason we don’t see multicol used much on the web is that it would be very easy to end up with a reading experience which made the reader scroll in the block dimension. That would mean scrolling up and down vertically for those of us using English or another vertical writing mode. This is not a good reading experience!”
That’s true. No one would enjoy repeatedly scrolling up and down to read a long passage of content set in columns. She went on:
“Neither of these things is ideal, and using multicol on the web is something we need to think about very carefully in terms of the amount of content we might be aiming to flow into our columns.”
But, let’s face it, thinking very carefully is what designers and developers should always be doing.
Sure, if you’re dumb enough to dump a large amount of content into columns without thinking about its design, you’ll end up serving readers a poor experience. But why would you do that when headlines, images, and quotes can span columns and reset the column flow, instantly improving readability? Add to that container queries and newer unit values for text sizing, and there really isn’t a reason to avoid using Multi-Column Layout any longer.
A brief refresher on properties and values
Let’s run through a refresher. There are two ways to flow content into multiple columns; first, by defining the number of columns you need using the column-count property:
Second, and often best, is specifying the column width, leaving a browser to decide how many columns will fit along the inline axis. For example, I’m using column-width to specify that my columns are over 18rem. A browser creates as many 18rem columns as possible to fit and then shares any remaining space between them.
Then, there is the gutter (or column-gap) between columns, which you can specify using any length unit. I prefer using rem units to maintain the gutters’ relationship to the text size, but if your gutters need to be 1em, you can leave this out, as that’s a browser’s default gap.
The final column property is that divider (or column-rule) to the gutters, which adds visual separation between columns. Again, you can set a thickness and use border-style values like dashed, dotted, and solid.
These examples will be seen whenever you encounter a Multi-Column Layout tutorial, including CSS-Tricks’ own Almanac. The Multi-Column Layout syntax is one of the simplest in the suite of CSS layout tools, which is another reason why there are few reasons not to use it.
Multi-Column Layout is even more relevant today
When I wrote Transcending CSS and first explained the emerging Multi-Column Layout, there were no rem or viewport units, no :has() or other advanced selectors, no container queries, and no routine use of media queries because responsive design hadn’t been invented.
We didn’t have calc() or clamp() for adjusting text sizes, and there was no CSS Grid or Flexible Box Layout for precise control over a layout. Now we do, and all these properties help to make Multi-Column Layout even more relevant today.
Now, you can use rem or viewport units combined with calc() and clamp() to adapt the text size inside CSS Columns. You can use :has() to specify when columns are created, depending on the type of content they contain. Or you might use container queries to implement several columns only when a container is large enough to display them. Of course, you can also combine a Multi-Column Layout with CSS Grid or Flexible Box Layout for even more imaginative layout designs.
Using Multi-Column Layout today
Patty Meltt is an up-and-coming country music sensation. She’s not real, but the challenges of designing and developing websites like hers are.
My challenge was to implement a flexible article layout without media queries which adapts not only to screen size but also whether or not a <figure> is present. To improve the readability of running text in what would potentially be too-long lines, it should be set in columns to narrow the measure. And, as a final touch, the text size should adapt to the width of the container, not the viewport.
Article with no <figure> element. What would potentially be too-long lines of text are set in columns to improve readability by narrowing the measure.
Article containing a <figure> element. No column text is needed for this narrower measure.
The HTML for this layout is rudimentary. One <section>, one <main>, and one <figure> (or not:)
<section> <main> <h1>About Patty</h1> <p>…</p> </main> <figure> <img> </figure> </section>
I started by adding Multi-Column Layout styles to the <main> element using the column-width property to set the width of each column to 40ch (characters). The max-width and automatic inline margins reduce the content width and center it in the viewport:
main margin-inline: auto; max-width: 100ch; column-width: 40ch; column-gap: 3rem; column-rule: .5px solid #98838F;
Next, I applied a flexible box layout to the <section> only if it :has() a direct descendant which is a <figure>:
section:has(> figure) display: flex; flex-wrap: wrap; gap: 0 3rem;
This next min-width: min(100%, 30rem) — applied to both the <main> and <figure> — is a combination of the min-width property and the min() CSS function. The min() function allows you to specify two or more values, and a browser will choose the smallest value from them. This is incredibly useful for responsive layouts where you want to control the size of an element based on different conditions:
section:has(> figure) main flex: 1; margin-inline: 0; min-width: min(100%, 30rem); section:has(> figure) figure flex: 4; min-width: min(100%, 30rem);
What’s efficient about this implementation is that Multi-Column Layout styles are applied throughout, with no need for media queries to switch them on or off.
Adjusting text size in relation to column width helps improve readability. This has only recently become easy to implement with the introduction of container queries, their associated values including cqi, cqw, cqmin, and cqmax. And the clamp() function. Fortunately, you don’t have to work out these text sizes manually as ClearLeft’s Utopia will do the job for you.
My headlines and paragraph sizes are clamped to their minimum and maximum rem sizes and between them text is fluid depending on their container’s inline size:
h1 font-size: clamp(5.6526rem, 5.4068rem + 1.2288cqi, 6.3592rem); h2 font-size: clamp(1.9994rem, 1.9125rem + 0.4347cqi, 2.2493rem); p font-size: clamp(1rem, 0.9565rem + 0.2174cqi, 1.125rem);
So, to specify the <main> as the container on which those text sizes are based, I applied a container query for its inline size:
main container-type: inline-size;
Open the final result in a desktop browser, when you’re in front of one. It’s a flexible article layout without media queries which adapts to screen size and the presence of a <figure>. Multi-Column Layout sets text in columns to narrow the measure and the text size adapts to the width of its container, not the viewport.
Modern CSS is solving many prior problems
Structure content with spanning elements which will restart the flow of columns and prevent people from scrolling long distances.
Prevent figures from dividing their images and captions between columns.
Almost every article I’ve ever read about Multi-Column Layout focuses on its flaws, especially usability. CSS-Tricks’ own Geoff Graham even mentioned the scrolling up and down issue when he asked, “When Do You Use CSS Columns?”
“But an entire long-form article split into columns? I love it in newspapers but am hesitant to scroll down a webpage to read one column, only to scroll back up to do it again.”
Fortunately, the column-span property — which enables headlines, images, and quotes to span columns, resets the column flow, and instantly improves readability — now has solid support in browsers:
h1, h2, blockquote column-span: all;
But the solution to the scrolling up and down issue isn’t purely technical. It also requires content design. This means that content creators and designers must think carefully about the frequency and type of spanning elements, dividing a Multi-Column Layout into shallower sections, reducing the need to scroll and improving someone’s reading experience.
Another prior problem was preventing headlines from becoming detached from their content and figures, dividing their images and captions between columns. Thankfully, the break-after property now also has widespread support, so orphaned images and captions are now a thing of the past:
figure break-after: column;
Open this final example in a desktop browser:
You should take a fresh look at Multi-Column Layout
Multi-Column Layout isn’t a shiny new tool. In fact, it remains one of the most underused layout tools in CSS. It’s had, and still has, plenty of problems, but they haven’t reduced its usefulness or its ability to add an extra level of refinement to a product or website’s design. Whether you haven’t used Multi-Column Layout in a while or maybe have never tried it, now’s the time to take a fresh look at Multi-Column Layout.
2 notes · View notes
eossa · 2 years ago
Text
Tumblr media Tumblr media
Vivale
Page 50 by @eossa
A responsive grid-based all-in-one page inspired by Pantone's color of the year 2023, "Viva Magenta".
For more information, please follow the source link or click here.
Grab the code here: buymeacoffee | ko-fi | payhip
8 notes · View notes
in-effyable · 2 years ago
Text
wow spent hours not understanding that what i was trying to do was nest grids, which is not what “inline grids” mean 🫠
4 notes · View notes
khushnuma123 · 5 months ago
Text
CSS Grid vs. Flexbox: Choosing the Right Layout Tool for Full Stack Developers
CSS Grid and Flexbox are both modern CSS layout techniques that make web design more flexible and efficient. Mastering these tools is crucial for Full Stack Developers, as they help create responsive and visually appealing designs. If you want to become a Full Stack Developer and gain top-notch skills, the Best Institute for Full Stack Developer Course in Pune, Mumbai, Nagpur, Delhi, Noida, and other cities in India is the perfect place for you. courses will deepen your understanding of essential tools like CSS Grid and Flexbox. Read on for more insights! 
0 notes
josegremarquez · 9 months ago
Text
Las Tablas en HTML5: Una Estructura Fundamental
¿Qué es una tabla? En HTML5, una tabla es una estructura que organiza datos en filas y columnas, proporcionando una forma clara y concisa de presentar información. Es ideal para mostrar listas de datos, bases de datos simplificadas o cualquier conjunto de información que requiera una organización visual. Importancia y Aplicaciones Presentación de datos: Tablas son perfectas para mostrar datos…
0 notes
jessicajournel-blog · 1 year ago
Text
Tumblr media
Responsive design ensures websites seamlessly adapt to any screen size. CSS Grid and Flexbox offer control, flexibility, and maintainability for modern, responsive layouts.
Flexbox Fundamentals
Single-direction layout (row or column)
Arranges elements within a container
Activates flexbox for container (display: flex)
Justify-content & align-items properties
Media queries for responsive adjustments
Handle overflow with flex-wrap
CSS Grid Fundamentals
Two-dimensional layout with rows & columns
Grid container holds the entire structure
Grid lines define layout organization
Grid-template-columns & grid-template-rows
Grid-auto-rows & grid-auto-columns
Media queries for responsive grids
The Power of Combining Flexbox & Grid
Nested Layouts: Create complex layouts with nested Flexbox containers for item arrangement within a CSS Grid structure.
Responsive Refinements: Fine-tune responsiveness with Flexbox properties like flex-wrap within a media query-driven Grid layout.
Alignment & Distribution Control: Leverage Flexbox properties like align-self for precise individual item alignment within a Grid container.
Modular & Reusable Components: Design reusable UI components with Flexbox for internal layout and Grid for overall positioning within the page.
0 notes
divinector · 1 year ago
Text
Tumblr media
Responsive Image Gallery with CSS Grid
1 note · View note
bruisedconscience-reblogs · 2 years ago
Text
61/100 Days of Code
Today, I'm feeling pretty great! Got CSS Grid Exercises #3 all completed and I'm rly happy with how it turned out! TIL, auto is absolutely your friend in CSS Grid.
I think I'll plow ahead into the next lessons. I have a better understanding of minmax(), autofit & autofill now... Not 100% but much better than I had been! (0%!!)
(PS: Please note this actual word of wisdom from TOP:
When doing the following exercises, please use all the documentation and resources you need to accomplish them. You are not intended to have any of this stuff memorized at this point. Check the docs, use google, do what you need to do (besides checking the solutions) to get them done.
So... I'd say I'm all good!! ❤️)
Edit: Also I love that it is called the Holy Grail Layout, tyvm
0 notes
dseval · 4 months ago
Text
Hello audience. Unfortunately, I am still on my break. However, I am happy to announce that I am still alive and kicking. In fact, I decided to make use of my unemployment and revisit HTML, CSS, and JavaScript to create... A visual novel.
Good News: code is 100% reusable because I used a JSON (i do not know how that works, someone can kindly explain to me...)
Bad News: this code sucks ass, and NOTHING works except playing the story. Transitions? Doesn't work. UI/UX? Ass. Effects? Hell no... Also, 70% of the features aren't present yet I'm gonna do it later.
Oh, this is CrossDust, if you can't tell.
Tumblr media Tumblr media
Dust Sans by Ask-Dusttale, Cross Sans by Jakei
I'm gonna respond to asks and do requests later (After my break is over). This is just a small update teehee.
23 notes · View notes
hezacodes · 2 years ago
Text
CSS Grid Guide
This CSS grid guide from CSS-Tricks is super helpful, and of course, if you're interested and want to check it out feel free to.
Happy Coding!
48 notes · View notes
gifti3 · 2 months ago
Text
the flexbox isnt doing what i want....!!!
Tumblr media
2 notes · View notes
newcodesociety · 1 year ago
Text
2 notes · View notes
codingflicks · 2 years ago
Text
Tumblr media
Responsive Neumorphism Service Section
5 notes · View notes
blushlyn · 2 years ago
Text
just found out i have to make a whole website by tuesday night…
if y’all don’t hear from it’s bc i’m crying trying to throw it together
2 notes · View notes