#css display grid
Explore tagged Tumblr posts
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.


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.
#dsevalyappuccino#TIME TO GO INSANE IN THE TAGS!!#i hate css#i still hate css#css hell no#guys why is css so hard. ive literally been doing this for months and css is still hard#i was about to use css spritesheets for the sprites and emotions#but my ass gave up and instead i just use seperate images#GUYS!!! DISPLAY: FLEX 💪. DISPLAY: GRID?!?!#javascript i hate you tooq#i hate java script naurrrr#what do you mean DOM objects#what do YOU MEAN#also i do not understand error handling and JSON integrations#papaGPT doesn't explain anything#i don't know what I just wrote#coding???????????#kids don't be unemployed#actually maybe if you're unemployed but still making money that's great#also the sprites are just for testing purposes im probably gonna make new better ones if i chose to expand this into#a full blown anime high school visual novel project#i don't wanna think of all that story crap but then again i can just write the cringiest thing on earth
23 notes
·
View notes
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.
#:has#ADD#almanac#Article#Articles#back up#background#book#box#browser#challenge#clamp#colours#columns#container#content#course#creators#CSS#CSS Grid#css-tricks#Design#designers#desktop#developers#digitalocean#display#easy#English#Explained
2 notes
·
View notes
Text
People who don't know much about web dev will go "fuck jQuery and the enshittification of the internet! Modern sites are bloated and inaccessible!" (which, to be fair, is true) and then go on to add so many unnecessary iframes to their neocities pages that the latest version of Firefox struggles to render them
#i promise using the display: grid css property will not suddenly turn you into a silicon valley corpobro#tangentially related:#i remember seeing someone boasting that their browser game was ''handcoded javascript''#ah yes i only visit websites that make use of ethically harvested small batch fair trade javascript
1 note
·
View note
Text
La propiedad display en CSS: Desde lo básico a los diseños más avanzados.
La propiedad display determina el tipo de caja que un elemento forma y cómo se comporta dentro del flujo del documento. En otras palabras, indica si un elemento se mostrará como un bloque, una línea o si se ocultará por completo. Valores de la propiedad display La propiedad display admite varios valores, cada uno con un comportamiento específico: Valores básicos: block: Crea un bloque que…
#block#caja#contenedor#CSS#CSS3#desarrollo web frontend#Diseño web#diseño web adaptable#diseño web moderno#elemento#elementos HTML#Flexbox#flujo del documento#Grid#inline#inline-block#layout#maquetación#posicionamiento de elementos#propiedad display#responsive design#tipos de display#valor display
0 notes
Text
webdev log uhhhh... 6?
Haven't worked on my site in a bit because I think I fucked up somewhere in during the deployment phase so now it's hard to host it locally.... only the index page works and the css is half broken anyways, presumably because of laravel breeze's tailwind coming preinstalled. I DID have to jump through hoops to get it going during deployment.. just don't know which hoops so it's stuck that way >_>;; so now I can't host it locally for development......... I'll have to make things and just hope it shows up when I deploy them I think
Failed to listen on 127.0.0.1:8000 (reason: ?)
cool, cool. thanks. very helpful debugging message..
anyways, coded up a little php doohicky and updated my site! WANNA PEEK?
I wanted to migrate my fridge page (art others have done of my characters) to my site, but I didn't want to implement another table because YUCK I'm so done with that.
I wanted something more automatic because I'm lazy and I also wanted it to not look like it's from 2003 like my neocities to match with my new site. too much trouble!!!! including the stuff previously mentioned.. so I left it untouched for a while.
then I was talking with someone and wanted to try making this with php.....
it's pretty basic. finished the code for the script in like an hour maybe, and then later it was mostly just tinkering with the html/css itself to make it display all nice and grid-like.
all it does is take all images from a specified folder and spits them out.
it creates a DirectoryIterator object to iterate through the specified folder (at least, I think that's how DirectoryIterator works.... dunno) then for each individual file it checks if it's an image, gets the time the file was modified, then stores the file path and modified time in an array. then that array gets sorted via modified time (newest first), and then iterated through and BAM...
I'd prefer a better time system such as organize when the file was actually created, but if you paste a file into a new folder, "created time" gets changed to when you pasted it.. using file modified time is the only way when you aren't using a database and just want this to be all done automatically I think. unless I'M STUPID and someone has a better idea.. then please enlighten me.
ANYWAYS added The Fridge to my site using my lil code! :>
updated my About to include a link too...
also, I was looking up things and found this funny example code on stack overflow
let's all randomize our racism images.....
5 notes
·
View notes
Text
widowbase v3 and v4
Whooboi, there is a lot of discourse going on right now about JCINK coders. Perfect time for me to update some base skins!
For those who just want to streamline their coding process, I have updated my widowbase v3 to include a day/night theme toggle and made a few responsive tweaks to the vertical nav and sidebar. For those looking to learn how to use CSS grid and flexbox to create responsive forum designs, I added a new base, widowbase v4. This version includes some HTML templates that have a very ugly, extremely basic, but functional fluid grid layout. These templates also incorporate hidden divs (read as, display: none) that include the PHP variables frequently used inside those respective HTML templates, so you can easily delete everything I've done and start from scratch with your own. Then just delete the hidden div when you've used everything you need. Easy peasy!
For those of you just beginning your coding journey, I wish you the best of luck! It is such a fun and rewarding hobby. You are also free to rip apart any of the codes on my preview site and cobble them back together. These experiments can be a great learning tool! You are more than welcome to use any of my free resources as a base, as long as the finished product remains free. As for my actual skin bases (or template sets specifically labeled as bases), these can be used for free or paid skins. Make money or give it away, whatever works for you, just leave the credits given to resources intact so others can find out how to accomplish the same thing!
36 notes
·
View notes
Note
(this is specific to scripts, not styling codes which ARE creative) // this is a tangent from the og conversation but none of the styling codes on jcink are creative or original. you can't claim color codes, rounded corner radius, stackoverflow, gooey menus, display, flex, grid, svg, cutouts, clip path, or any other css element as original. some might be new or newly brought back to jcink but they are everywhere on the internet. ppl get mad about "stolen" ideas and the idea is a clip path lol
~
2 notes
·
View notes
Text
꒰ ͙ ❄ SHOW ME UR GIFFIES . ꒱
greetings , pookies ! SHOW ME UR GIFFIES is a fun , vibrant lil gem of a page to host and display all of ur beautiful gifs ! there are two versions available to download , one suited for gif icons and one suited for larger gifs . sizes were tested with 70 x 70 px icons and 268 x 150 px gifs but should be accommodating to various sizing discrepancies ! there are annotations through the page to help u get the precise look u want . as per usual , let me know if u encounter any errors and i will do my best to troubleshoot asap !
if u intend on using this theme or just want to be a supportive hottie , please give this post a like and a reblog ! stay hydrated and be sure to pet a cute animal today ! mwuah 💋 💋 💋 !
ⅰ. THEME FEATURES .
x. 100% java free x. cute , geometric grid line background x. aesthetically pleasing gradient wave header w / annotations to help change the colors + link to shade finder software to help u design ur gradient x. pill - shaped container to house ur title and other goodies x. designated area for ur description x. animated pill container to state gif count x. five links in mini nav hub ; one to redirect to ur main , one to go to ur inbox , one to link to ur main list of resources , one to direct users to ur commission info ( if applicable ) , and one to bring the user back to the dash . all of these links can be edited / deleted to ur liking x. detailed annotations to edit ur page's margins and padding x. optional ::before sector to add symbols / emojis before ur title that are customizable in the css x. links for various unicode character / emoji resources within the code to use for ur title x. for a more detailed compilation of credits and features , please see the google doc containing the code
͙ ❄ this page is a patreon exclusive : want access ? consider signing up to join the fam - a - lam to get ur hands on this theme as well as my entire coding catalogue . click here to learn more !
source link directs to a live preview of SHOW ME UR GIFFIES ! original gif icon drop of cierra ramirez can be found here .
#rph#rpt#indie rph#rp theme#rp page#gif page#mine#rec#for patreons#for patrons#round 2 bc my previous post wasn't appearing ???
21 notes
·
View notes
Text
am i dumb
today i feel defeated because i didn't know you could put a css grid within a grid during this exercise i was doing. it wasn't shown in the tutorial and i only knew because i compared my code with the model code. so when i found out i was ike ???#%#$?^$&
i was so stuck on why this text was below a photo instead of sitting next to it and i feel like i should've known??
i'm just beating myself up at this point but i really couldn't put the pieces together and i'm sad that i'm DUM.
i mean i understand it now but AT WHAT COSTTT it felt like i was blatantly copying what the instructor put in their code even though it kinda wasn't so i feel like a fraud but a dummy at the same time bc i couldn't figure that out :(((((((((((((
this is an example of the problem i was facing:
#real #true
context: the lesson was introducing css grid and explaining how display inline blocks don't automatically apply vertical alignment so grids are better.
here is my html and css for these example i made and whatnot:
(these contain div elements using the nested layouts technique)
2. i put them in a grid and removed the inline blocks as told by the tutorial (photo is at 100% width) and the text ended up like this:
the text is below the icon now (rounded photo)
3. found out that the instructor put a grid within the text and icon and so i did the same thing and
this is the html and css + the final outcome:
skjdnwesfh;kjrbgjbfjbgkjrdngkdjtfgnjdfbgrehb
tjgnrjgnregjbr
if i couldn't figure this simple thing out on my own
how will i figure anything out on my own
rip #aminotcutoutforthis #lordsend helpkwe;l;fwef
19 notes
·
View notes
Text
Update: State of my Website
Over the last few days, I went from not having a website to having my own website, having a social wall, having a blog, and basically linking everything to everything.
I have also added a blogroll, so that people can actually leave my website following their own urge to surf the web.
But I think the most radical thing I did was take inspiration from an ebook I am currently reading: Interpassivity, by Robert Pfaller, or rather from the way it looks and reads, if this verb allows for being changed into something an object does, instead of being something done with an object you can read.
Ebooks are, similar to how apps are these days, wrapped web pages: they are basically html and css (and javacript, if you look at apps).
So I studied why I found this ebook such easily readable, and it turns out that it is for the simple fact, that, all by itself, it was set to display in Times New Roman. Should that typeface not exist, then it would be displayed in Times, and if that, too, should fail, just a Serif typeface (like I first tried with Georgia, but I really didn’t like Georgia’s bombastic medieval numerals, it felt like a winery!).
There is still some tweaking to be done (based around my knowledge of typographic detail and grids, I need to take a second look at line height and how far paragraphs are spaced out vertically), but having done this change all I can say is that I am amazed by how readable my website and my blogged articles suddenly are.
It honestly feels like doing something new, because basically everyone is doing the custom typeface, sans‑serif for everything, really, while, what I think, the eye of the reader suffers for it.
The screenshots above were made while my Dark Reader plugin was active, so don’t be surprised that the real thing looks different ;)
There is also this bonus effect of how Serifs are connected to authority, and despite what the Bauhaus nerds tell us graphic designers in a top‑down abstraction, authority is good, especially if it comes for free by increasing the readability.
#work in progress#grafikdesign#build in public#graphic design#learning design#learn design#typography#readability#times new roman#ebooks#epub#code and canvas
2 notes
·
View notes
Text
AGARTHA Aİ - DEVASA+

In today's digital age, a well-designed website is essential for success, but the cost of professional web design can often be a barrier for many businesses. Fortunately, affordable web design services have emerged as a viable solution, ensuring that everyone—from startups to established small businesses—can establish an impressive online presence without breaking the bank. This blog post will explore the various aspects of affordable web design services, highlighting what to look for in a reliable website service, the importance of responsive web design, and how budget-friendly options can specifically cater to the unique needs of small businesses.
Affordable web design services
In today’s digital landscape, affordable web design services have become essential for businesses of all sizes. With an increasing number of consumers turning to the internet for their needs, having a professional and attractive website is more critical than ever. Many small businesses and startups often worry that they cannot afford high-quality web design, but there are plenty of options available that offer both quality and cost-effectiveness.
One of the main advantages of choosing affordable web design services is the ability to find packages that fit various budgets without sacrificing quality. Many web design agencies understand the needs of small businesses and offer tailored solutions that ensure a professional presentation without overwhelming financial commitments. This is especially beneficial for startups that are eager to establish a digital presence without breaking the bank.
Moreover, many affordable web design services provide flexibility in their offerings, allowing clients to select features that meet their specific requirements. From simple informational websites to more complex e-commerce solutions, the variety available in budget-friendly web design ensures that every business can find a service that aligns with its goals and vision. Investing in affordable web design not only enhances a brand's credibility but also helps reach a wider audience effectively.
Website service
In today's digital age, having a robust website service is essential for both businesses and individuals. A well-designed website serves as the online face of a company and is often the first point of contact for potential customers. Investing in quality website service can significantly enhance your online presence and build trust with your audience.
Choosing the right website service provider is crucial. Look for companies that offer customized solutions tailored to your unique needs. This ensures that the website not only looks good but also functions effectively, providing an optimal user experience. A reliable website service provider should provide ongoing support and maintenance to keep your site running smoothly.
Moreover, an effective website service should prioritize SEO optimization, ensuring that your site ranks well in search engine results. This is vital as higher visibility leads to increased traffic and potential sales. Remember, a great website is more than just beautiful design; it's about delivering a seamless user experience
Responsive web design
Responsive web design is an essential approach to creating websites that provide an optimal viewing experience across a wide range of devices. With the increase in mobile device usage, it has become crucial for businesses to ensure that their websites function seamlessly on smartphones, tablets, and desktops. Designing with responsiveness in mind leads to a more user-friendly experience, which can significantly impact user engagement and conversion rates.
One of the key principles of responsive web design is the use of flexible layouts and grid systems. This allows elements on the page to resize and reposition themselves according to the screen size. By employing CSS media queries, designers can tailor styles for different devices, ensuring that content is displayed appropriately without compromising on aesthetics or functionality.
Moreover, implementing responsive web design is not just beneficial for users, but it also plays a vital role in search engine optimization (SEO). Search engines like Google prioritize mobile-friendly websites in their rankings. Therefore, having a site that is responsive can lead to better visibility in search results, driving more organic traffic to your website.
Affordable web design for small business
In today's digital age, every small business needs a strong online presence to compete effectively. However, finding affordable web designfor small business can be a daunting task for many entrepreneurs. It's essential to strike a balance between quality design and budget constraints.
One of the best ways to achieve this is by opting for responsive web design. This approach ensures that your website not only looks great on desktop but also provides an excellent user experience on mobile devices. Since a significant portion of web traffic comes from smartphones, investing in responsive design is crucial for small businesses seeking to maximize their reach.
There are numerous platforms offering affordable web design packages specifically tailored for small businesses. These services can help you establish a professional look without breaking the bank. By choosing the right designer, you can create a site that reflects your brand and meets your customers' needs while staying within your budget.
46 notes
·
View notes
Text
Tailwind’s @apply Feature is Better Than it Sounds
New Post has been published on https://thedigitalinsider.com/tailwinds-apply-feature-is-better-than-it-sounds/
Tailwind’s @apply Feature is Better Than it Sounds


By this point, it’s not a secret to most people that I like Tailwind.
But, unknown to many people (who often jump to conclusions when you mention Tailwind), I don’t like vanilla Tailwind. In fact, I find most of it horrible and I shall refrain from saying further unkind words about it.
But I recognize and see that Tailwind’s methodology has merits — lots of them, in fact — and they go a long way to making your styles more maintainable and performant.
Today, I want to explore one of these merit-producing features that has been severely undersold — Tailwind’s @apply feature.
What @apply does
Tailwind’s @apply features lets you “apply” (or simply put, copy-and-paste) a Tailwind utility into your CSS.
Most of the time, people showcase Tailwind’s @apply feature with one of Tailwind’s single-property utilities (which changes a single CSS declaration). When showcased this way, @apply doesn’t sound promising at all. It sounds downright stupid. So obviously, nobody wants to use it.
/* Input */ .selector @apply p-4; /* Output */ .selector padding: 1rem;
To make it worse, Adam Wathan recommends against using @apply, so the uptake couldn’t be worse.
Confession: The `apply` feature in Tailwind basically only exists to trick people who are put off by long lists of classes into trying the framework.
You should almost never use it 😬
Reuse your utility-littered HTML instead.https://t.co/x6y4ksDwrt
— Adam Wathan (@adamwathan) February 9, 2020
Personally, I think Tailwind’s @apply feature is better than described.
Tailwind’s @apply is like Sass’s @includes
If you have been around during the time where Sass is the dominant CSS processing tool, you’ve probably heard of Sass mixins. They are blocks of code that you can make — in advance — to copy-paste into the rest of your code.
To create a mixin, you use @mixin
To use a mixin, you use @includes
// Defining the mixin @mixin some-mixin() color: red; background: blue; // Using the mixin .selector @include some-mixin(); /* Output */ .selector color: red; background: blue;
Tailwind’s @apply feature works the same way. You can define Tailwind utilities in advance and use them later in your code.
/* Defining the utility */ @utility some-utility color: red; background: blue; /* Applying the utility */ .selector @apply some-utility; /* Output */ .selector color: red; background: blue;
Tailwind utilities are much better than Sass mixins
Tailwind’s utilities can be used directly in the HTML, so you don’t have to write a CSS rule for it to work.
@utility some-utility color: red; background: blue;
<div class="some-utility">...</div>
On the contrary, for Sass mixins, you need to create an extra selector to house your @includes before using them in the HTML. That’s one extra step. Many of these extra steps add up to a lot.
@mixin some-mixin() color: red; background: blue; .selector @include some-mixin(); /* Output */ .selector color: red; background: blue;
<div class="selector">...</div>
Tailwind’s utilities can also be used with their responsive variants. This unlocks media queries straight in the HTML and can be a superpower for creating responsive layouts.
<div class="utility1 md:utility2">…</div>
A simple and practical example
One of my favorite — and most easily understood — examples of all time is a combination of two utilities that I’ve built for Splendid Layouts (a part of Splendid Labz):
vertical: makes a vertical layout
horizontal: makes a horizontal layout
Defining these two utilities is easy.
For vertical, we can use flexbox with flex-direction set to column.
For horizontal, we use flexbox with flex-direction set to row.
@utility horizontal display: flex; flex-direction: row; gap: 1rem; @utility vertical display: flex; flex-direction: column; gap: 1rem;
After defining these utilities, we can use them directly inside the HTML. So, if we want to create a vertical layout on mobile and a horizontal one on tablet or desktop, we can use the following classes:
<div class="vertical sm:horizontal">...</div>
For those who are new to Tailwind, sm: here is a breakpoint variant that tells Tailwind to activate a class when it goes beyond a certain breakpoint. By default, sm is set to 640px, so the above HTML produces a vertical layout on mobile, then switches to a horizontal layout at 640px.
If you prefer traditional CSS over composing classes like the example above, you can treat @apply like Sass @includes and use them directly in your CSS.
<div class="your-layout">...</div>
.your-layout @apply vertical; @media (width >= 640px) @apply horizontal;
The beautiful part about both of these approaches is you can immediately see what’s happening with your layout — in plain English — without parsing code through a CSS lens. This means faster recognition and more maintainable code in the long run.
Tailwind’s utilities are a little less powerful compared to Sass mixins
Sass mixins are more powerful than Tailwind utilities because:
They let you use multiple variables.
They let you use other Sass features like @if and @for loops.
@mixin avatar($size, $circle: false) width: $size; height: $size; @if $circle border-radius: math.div($size, 2);
On the other hand, Tailwind utilities don’t have these powers. At the very maximum, Tailwind can let you take in one variable through their functional utilities.
/* Tailwind Functional Utility */ @utility tab-* tab-size: --value(--tab-size-*);
Fortunately, we’re not affected by this “lack of power” much because we can take advantage of all modern CSS improvements — including CSS variables. This gives you a ton of room to create very useful utilities.
Let’s go through another example
A second example I often like to showcase is the grid-simple utility that lets you create grids with CSS Grid easily.
We can declare a simple example here:
@utility grid-simple display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: var(--gap, 1rem);
By doing this, we have effectively created a reusable CSS grid (and we no longer have to manually declare minmax everywhere).
After we have defined this utility, we can use Tailwind’s arbitrary properties to adjust the number of columns on the fly.
<div class="grid-simple [--cols:3]"> <div class="item">...</div> <div class="item">...</div> <div class="item">...</div> </div>
To make the grid responsive, we can add Tailwind’s responsive variants with arbitrary properties so we only set --cols:3 on a larger breakpoint.
<div class="grid-simple sm:[--cols:3]"> <div class="item">...</div> <div class="item">...</div> <div class="item">...</div> </div>
This makes your layouts very declarative. You can immediately tell what’s going on when you read the HTML.
Now, on the other hand, if you’re uncomfortable with too much Tailwind magic, you can always use @apply to copy-paste the utility into your CSS. This way, you don’t have to bother writing repeat and minmax declarations every time you need a grid that grid-simple can create.
.your-layout @apply grid-simple; @media (width >= 640px) --cols: 3;
<div class="your-layout"> ... </div>
By the way, using @apply this way is surprisingly useful for creating complex layouts! But that seems out of scope for this article so I’ll be happy to show you an example another day.
Wrapping up
Tailwind’s utilities are very powerful by themselves, but they’re even more powerful if you allow yourself to use @apply (and allow yourself to detach from traditional Tailwind advice). By doing this, you gain access to Tailwind as a tool instead of it being a dogmatic approach.
To make Tailwind’s utilities even more powerful, you might want to consider building utilities that can help you create layouts and nice visual effects quickly and easily.
I’ve built a handful of these utilities for Splendid Labz and I’m happy to share them with you if you’re interested! Just check out Splendid Layouts to see a subset of the utilities I’ve prepared.
By the way, the utilities I showed you above are watered-down versions of the actual ones I’m using in Splendid Labz.
One more note: When writing this, Splendid Layouts work with Tailwind 3, not Tailwind 4. I’m working on a release soon, so sign up for updates if you’re interested!
#ADD#Advice#approach#Article#Articles#avatar#background#Blue#border#border-radius#Building#classes#code#Color#columns#CSS#CSS Grid#css preprocessors#desktop#direction#display#easy#effects#English#Features#framework#gap#grid#grid-template-columns#grids
0 notes
Text
Build Clean, Modern UIs with Golden Ratio Scaling - LiftKit CSS
LiftKit CSS is a lightweight, 100% free CSS framework developed by Chainlift. It’s a set of utility classes and UI components designed with golden ratio scaling, which helps you create clean, modern web projects. Utility Classes: Color Typography Spacing Grids Sizes Border Radius Aspect Ratio Shadow Layout Blocks Display UI Elements: Cards Badges Stickers Buttons Navigation Snackbar More…

View On WordPress
2 notes
·
View notes
Text
Propiedades CSS para dar ay una apariencia similar a etiquetas semánticas
Propiedades CSS para dar a <div> y <section> una apariencia similar a etiquetas semánticas Si bien las etiquetas semánticas como <header>, <section>, <aside>, y <footer> ofrecen un significado inherente a su contenido, las etiquetas <div> y <section> son más genéricas y requieren de estilos CSS para definir su apariencia y comportamiento. A continuación, te presento algunas propiedades CSS que…
#block#CSS#diseño responsive#Diseño web#display#elementos HTML#Flexbox#Grid#inline#inline-block#layout#propiedades CSS
0 notes
Text
Responsive Web Design: Best Practices for Optimal User Experience and SEO
In today’s digital age, where the majority of internet users access websites through various devices, responsive web design has become paramount. It’s not just about making a website look good; it’s about ensuring seamless functionality and accessibility across all screen sizes and devices. Responsive web design (RWD) is a critical approach that allows websites to adapt to different devices and screen sizes, providing an optimal viewing and interaction experience.
Importance of Responsive Web Design:
Responsive web design is essential for several reasons. Firstly, it improves user experience by ensuring that visitors can easily navigate and interact with the website regardless of the device they’re using. This leads to higher engagement, lower bounce rates, and increased conversion rates. Secondly, with the proliferation of mobile devices, responsive design is crucial for reaching a wider audience. Google also prioritizes mobile-friendly websites in its search results, making responsive design a key factor for SEO success.
Key Principles to Follow:
Fluid Grids: Instead of fixed-width layouts, use fluid grids that can adapt to different screen sizes.
Flexible Images and Media: Ensure that images and media elements can resize proportionally to fit various devices.
Media Queries: Utilize CSS media queries to apply different styles based on screen characteristics such as width, height, and resolution.
Mobile-First Approach: Start designing for mobile devices first, then progressively enhance the layout for larger screens.
Performance Optimization: Optimize website performance by minimizing HTTP requests, reducing file sizes, and leveraging caching techniques.
Tips for Optimization:
Prioritize Content: Display essential content prominently and prioritize functionality for mobile users.
Optimize Touch Targets: Make buttons and links large enough to be easily tapped on touchscreen devices.
Viewport Meta Tag: Use the viewport meta tag to control how the webpage is displayed on different devices.
Testing Across Devices: Regularly test the website across various devices and browsers to ensure consistent performance and appearance.
Progressive Enhancement: Implement features in layers, starting with basic functionality and progressively enhancing it for more capable devices.
Impact on User Experience:
Responsive web design directly impacts user experience by providing a seamless and consistent experience across devices. Users no longer have to pinch and zoom or struggle with tiny buttons on their smartphones. Instead, they can effortlessly navigate through the website, leading to higher satisfaction and engagement. A positive user experience ultimately translates into increased conversions and customer loyalty.
SEO and Responsive Design:
Responsive web design plays a significant role in SEO. Google, the leading search engine, recommends responsive design as the best practice for mobile optimization. Responsive websites have a single URL and HTML code, making it easier for search engines to crawl, index, and rank content. Additionally, responsive design eliminates the need for separate mobile websites, preventing issues such as duplicate content and diluted link equity.
Real-Life Examples:
Apple: Apple’s website seamlessly adapts to different screen sizes, providing an optimal browsing experience on both desktops and mobile devices.
Amazon: Amazon’s responsive design ensures that users can easily shop and navigate through its vast catalog on any device, contributing to its success as a leading e-commerce platform.
HubSpot: HubSpot’s website is a prime example of a responsive design that prioritizes content and functionality, catering to users across various devices.
Conclusion:
In conclusion, responsive web design is not just a trend; it’s a necessity in today’s digital landscape. By adhering to best practices and optimizing for user experience, websites can effectively reach and engage audiences across desktops, smartphones, and tablets. As Google continues to prioritize mobile-friendly websites, investing in responsive design is crucial for maintaining visibility and driving organic traffic. Embrace responsive design to stay ahead in the competitive online ecosystem.
Web Development Services:
Blockverse Infotech Solutions has been a pioneer in providing exceptional web development and design services for the past five years. With a dedicated team of professionals, Blockverse ensures cutting-edge solutions tailored to meet clients’ specific needs. Whether you’re looking to create a responsive website from scratch or revamp your existing platform, Blockverse Infotech Solutions delivers innovative designs and seamless functionality to elevate your online presence. Trust Blockverse for all your web development and design requirements and witness your digital vision come to life.
3 notes
·
View notes
Text
The Marvel of Responsive Web Design: Navigating a User-Centric Digital Landscape
Hey there, fellow web enthusiasts it's your digital marketing agency in Dwarka, vrankup! 🌐 In today's fast-paced digital realm, where every swipe, tap, and click could lead you down a rabbit hole of information and entertainment, web design has evolved into an art of seamless adaptation. Welcome to this exciting ride through the dynamic universe of responsive web design! Buckle up as we delve deep into why it matters, the nitty-gritty of its principles, and a treasure trove of best practices that can transform your web creations. Whether you're sipping coffee on a desktop or thumbing through your smartphone, this guide will be your trusty co-pilot through the responsive web galaxy. The Responsive Revolution Picture this: You're hunched over your laptop, meticulously crafting the perfect website layout. Now, visualize your masterpiece on a smartphone screen. Wait, why does it look like a Picasso on steroids? That's where responsive web design swoops in like a superhero! 🦸♂️ It's the technique that makes your website adjust effortlessly to fit screens of all sizes, from colossal desktop monitors to those itty-bitty smartphone displays. The idea is to give users a seamless experience, regardless of their device. Imagine that - no more awkward pinching, zooming, or squinting. Responsive web design is the key to a harmonious user journey. Why It's the Real Deal First off, let's talk about our gadgets. They're our sidekicks - always with us, whether we're lounging at home or conquering the concrete jungle. With users switching between smartphones, tablets, laptops, and whatnot, your website must be adaptable. That's where responsive design steps in, ensuring your content shines, no matter the screen size. But there's more! Think about Google and its SEO ranking algorithm. It adores mobile-friendly sites, boosting their visibility in search results. So, if you're aiming for web stardom, responsiveness is your ticket to SEO success.
|Digital marketing agency in dwarka| Responsive Design: Unveiling the Magic Hold on to your digital hats, because here come the secret ingredients of responsive web design! 🎩💫 1. Fluid Grids: It's like having a shape-shifting foundation for your website. Instead of fixed-width layouts that look wonky on different screens, fluid grids use relative units (like percentages) to make your content flow smoothly. It's like having a web design dance party that adapts to every beat. 2. Flexible Images: Ah, images - the pièce de résistance of any website. Responsive design makes sure they behave like chameleons, adapting to their surroundings. CSS tricks like 'max-width: 100%' keep images from breaking the layout on smaller screens. And with HTML's 'srcset' attribute, you can provide different images based on the device, like a magician changing outfits for different acts. 3. Media Queries: These are like the responsive design spells in your web development wizardry book. With media queries, you can sprinkle CSS rules that alter your design based on the device's traits - be it screen width, height, or orientation. Imagine your website's design adjusting its makeup as it transitions from a smartphone to a tablet! Best Practices: Crafting a Responsive Masterpiece Ready to craft your own responsive symphony? Here's the sheet music - our top-notch best practices! 1. Mobile-First Approach: Think small, my friend. Start designing for mobile devices first and work your way up. This approach keeps your design lean, focusing on the essentials for the smallest screens and then adding embellishments for larger ones. 2. Use Relative Units: Pixels, schmixels! Embrace relative units like percentages, ems, and rems for fonts, padding, and margins. They're like the universal translators of responsive design, ensuring your website understands the language of all devices. 3. Extensive Testing: Before the big show, run dress rehearsals on real devices and simulators. Test, test, and test again! Check if your navigation is smooth, images scale gracefully, and your layout waltzes beautifully on screens of all sizes. 4. Performance Tune-up: Mobile users are all about speed - no one likes waiting in a virtual queue. Compress images, minify CSS and JavaScript files, and consider lazy loading to keep your responsive creation loading lightning-fast. 5. User-Centric Design: Keep your users at the heart of it all. Focus on delivering what they need most, especially on smaller screens. Trim the excess and let the essentials shine through. The Grand Finale Responsive web design isn't just a tool in your arsenal - it's a mindset. It's about embracing change and ensuring your digital creations are welcoming to everyone, no matter the device they wield. As technology continues its relentless march forward, responsive design ensures your website remains relevant, accessible, and captivating to users old and new. So, there you have it, intrepid explorers of the web cosmos! With the principles and best practices of responsive design in your toolkit, you're well-equipped to navigate the dynamic tides of the digital sea. As screens continue to shrink, expand, and evolve, your websites will stand strong, adaptable, and ready to provide users with an experience that's nothing short of extraordinary. Get out there and design responsively - the digital realm awaits your creative brilliance! 🚀 Catch you later, Digital marketing agency in dwarka, vrankup!
#website designing company in dwarka#seo company#seo#website designing company in gurgaon#noida#digital marketing#digital marketing agency in dwarka#vrankup#digital marketing company in dwarka#website designing services in gurgaon
2 notes
·
View notes