Collective #744




Our Sponsor

Explore the world like a local with Babbel

If you’ve always wanted to learn a new language, Babbel will be the most productive 10 minutes of your day. Trusted by over 10 million subscribers worldwide, the subscription-based language learning platform can get you confidently conversing in a new tongue in just three weeks. This isn’t your grade school textbook: the bite-sized lessons, available in 14 languages, teach you localized vocabulary you’ll actually use in the real world. Plus, speech recognition technology helps you perfect your accent. Sign up today and get up to 60 percent off your subscription.

Learn more



Crafty Amigo

A free 3D design app built by Navid Safabakhsh after learning from the Three.js course by Bruno Simon.

Check it out



CSS Style Queries

Ahmad Shadeed takes a look at CSS container style queries and shows what we can do with them.

Read it


D2 Playground

An online runner to play, learn, and create with D2, the modern diagram scripting language that turns text to diagrams.

Check it out


2022 CSS Updates

The 10th door of this year’s 12 Days of Web edition, is Stephanie Eckles’s article where she reviews eleven exciting additions to CSS that became fully or nearly cross-browser in 2022.

Read it

















Our Sponsor

Get access to marketing and sales resources here

Whether you’re looking to land the next promotion or solve a sales or marketing challenge at work, The Juice can help. The ultimate industry insider hack, The Juice aggregates career-enhancing resources from top brands and thought leaders and organizes them in one place, so you don’t have to keep filling out marketing forms for access (or dodging sales calls yourself). Start thinking like top B2B marketers and sales professionals with The Juice.

Check it out

Collective #727



collective 727 item image
Our Sponsor

Our annual Summer Sale is back! This is one of only a few times we offer our biggest discounts. Get 20% off Divi, 40% off Divi Cloud and up to 50% off products in the Divi Marketplace!

Get the deal







collective 727 item image

VRSEAT

An immersive 3D experience using Three.js for a seat picker that emulates the experience. A new project by Anderson Mancini.

Check it out












collective 727 item image

lllove

An SVG heart maker that makes it easy to design heart shapes and save them as SVG to use in your print or web designs.

Check it out



collective 727 item image

Popsy

A no-code website builder that works like Notion where you can customize a design and publish.

Check it out


collective 727 item image

WebKit on GitHub!

Read how the WebKit project froze its Subversion tree and transitioned management and interaction with source code to git on GitHub.

Check it out




collective 727 item image

Digs.fm

Track and organize music releases you want to listen, listened or liked.

Check it out



Collective #706












Yaade

Yaade is an open-source, self-hosted, collaborative API development environment.

Check it out





Nitric

Nitric is a framework for rapid development of cloud-native and serverless applications.

Check it out



How We Built r/Place

A super interesting article on how Reddit’s Place was built, a collaborative canvas on which a single user could only place a single tile every five minutes.

Read it



Range

A fun and creative way to use the range slider 🙂 Made by Hakim El Hattab.

Check it out







The post Collective #706 appeared first on Codrops.

Collective #703







What Is ARIA Even For?

Heydon Pickering’s amusing video about common pitfalls of using ARIA with the help of Ada Lovelace, a goat, and a dinosaur with a table for a head.

Watch it


Texture

Bring your generative work to life with three simple textures inspired by the natural world. By George Francis.

Check it out



Roland50.studio

Emulate the sound of Roland’s most famous and influential musical instruments from Yuri Suzuki and Roland.

Check it out










In Defense of Sass

Stephanie Eckles writes how organization, linting, and ease of theming are the primary reasons she’ll continue to use Sass.

Read it


Skateboard-Like Preloader

A fun preloader concept featuring a worm that does a flip when reaching the left or right sides of the ring. Made with SVG and CSS animation by Jon Kantner.

Check it out



SILVER FCTRY

Experience the playful and immersive AMBUSH® universe, in a virtual spaceship to take you on a journey to the other side.

Check it out



The post Collective #703 appeared first on Codrops.

Collective #700



Collective 700 Item image

Our Sponsor

Build Using the DoorDash API

DoorDash Developer allows you to easily integrate delivery services into your website or app. We’ve created the API, you set the rules, offer delivery on your terms and only pay for what you use. And integration is incredibly easy.

Get Started









Collective 700 Item image

MicroWaver 59™

A fun game: Fifty-nine seconds of delicious, electromagnetic horsepower. Are you hungry for the future? Insert a coin and wave away inside this hyper-interactive food machine. By Pink Yellow.

Check it out






Collective 700 Item image

Shaders and Gradients

The second issue of Offscreen Canvas is about learning shaders and explores why gradients are so important, and more.

Read it




Collective 700 Item image

Google Search Is Dying

A very interesting article on how Reddit is currently the most popular search engine and how Google Search is not working anymore the way it should.

Check it out



Collective 700 Item image

In case you didn’t know about it: jless is a command-line JSON viewer designed for reading, exploring, and searching through JSON data.

Check it out




The post Collective #700 appeared first on Codrops.

Collective #697



Creating a Schema-Based Form System

Tania Rascia shows how to make a form system where we can simply define the schema of a form and pass it into a component that takes care of all the common form needs.

Read it








Inclusive Design

Read about inclusive design which describes methodologies to create products that understand and enable people of all backgrounds and abilities.

Check it out





California Design System

The California Design System makes it easy for state digital teams to build accessible, consistent, and performant services and products. Interesting to learn from.

Check it out




dddraw

A free and simple online drawing tool that makes it easy to freehand draw SVGs.

Check it out





SkyBot

Super cool project: Luke Berndt made a system that shoots photos of all the airplanes that fly over his house.

Check it out


The post Collective #697 appeared first on Codrops.

Collective #688



Codrops Collective 687 image

Our Sponsor

Black Friday is Coming

Any time between now and Nov 26th you can enter to win a brand new MacBook Pro. Entering is completely free and the more raffle tickets you submit the better chance you have to win!

Enter now
















Collective 688 item image

Rows

Spreadsheets with built-in integrations from your business apps and team support.

Check it out




Collective 688 item image

Unocss

In case you didn’t know about it: The instant on-demand Atomic CSS engine inspired by Windi CSS, Tailwind CSS, Twind.

Check it out



The post Collective #688 appeared first on Codrops.

Collective #686




Codrops Collective item image

Codeamigo

A new community-based platform that allows anyone to take free interactive coding tutorials.

Check it out






Codrops Collective item image

llline

SVG generator that makes it easy to create lines & strokes that look and feel organic.

Check it out





Codrops Collective item image

Toxiproxy

A TCP proxy to simulate network and system conditions for chaos and resiliency testing.

Check it out



Codrops Collective item image

MangoDB

MangoDB is set out to become the de-facto open-source alternative to MongoDB.

Check it out




Codrops Collective item image

Notifire

An open-source notification infrastructure for products with multi channel communication via email, sms, push and more.

Check it out





Codrops Collective item image

Mistql

MistQL is a miniature embeddable query language for JSON-like structures, built for embedding within applications.

Check it out


The post Collective #686 appeared first on Codrops.

Collective #680




Theatre.js

Theatre.js is a new hackable JavaScript animation library with visual tools. It animates the DOM, WebGL, and any other JavaScript variable.

Check it out









Open-Meteo

Open-Meteo offers free weather forecast APIs for open-source developers and non-commercial use. No API key is required.

Check it out


Mechanic

Mechanic is an open source framework that makes it easy to create custom, web-based design tools that export design assets right in your browser.

Check it out




Glass

Glass is a new subscription-based photo sharing app and community for professional and amateur photographers alike without dark patterns driving engagement.

Check it out



Standards

A new way to design brand guidelines. A product from Standards Manual. Apply for early access.

Check it out


Q1K3

An incredible Quake clone made by Dominic Szablewski for the 2021 js13k competition.

Check it out


The post Collective #680 appeared first on Codrops.

Container Units Should Be Pretty Handy

Container queries are going to solve this long-standing issue in web design where we want to make design choices based on the size of an element (the container) rather than the size of the entire page. So, if a container is 600px wide, perhaps it has a row-like design, but any narrower than that it has a column-like design, and we’ll have that kind of control. That’s much different than transitioning between layouts based on screen size.

We can already size some things based on the size of an element, thanks to the % unit. For example, all these containers are 50% as wide as their parent container.

The % here is 1-to-1 with the property in use, so width is a % of width. Likewise, I could use % for font-size, but it will be a % of the parent container’s font-size. There is nothing that lets me cross properties and set the font-size as a % of a container’s width.

That is, unless we get container units! Here’s the table of units per the draft spec:

unitrelative to
qw1% of a query container’s width
qh1% of a query container’s height
qi1% of a query container’s inline size
qb1% of a query container’s block size
qminThe smaller value of qi or qb
qmaxThe larger value of qi or qb

With these, I could easily set the font-size to a percentage of the parent container’s width. Or line-height! Or gap! Or margin! Or whatever!

Miriam notes that we can actually play with these units right now in Chrome Canary, as long as the container queries flag is on.

I had a quick play too. I’ll just put a video here as that’ll be easier to see in these super early days.

And some great exploratory work from Scott here as well:

Ahmad Shadeed is also all over this!

Query units can save us effort and time when dealing with things like font-sizepadding, and margin within a component. Instead of manually increasing the font size, we can use query units instead.

Ahmad Shadeed, “CSS Container Query Units”

Maybe container queries and container units will drop for real at the same time. 🤷


The post Container Units Should Be Pretty Handy appeared first on CSS-Tricks. You can support CSS-Tricks by being an MVP Supporter.

Collective #667

















Collective 667 item image

GitHub Issues

With the new GitHub Issues you can break issues into tasks, track relationships, add custom fields, and have conversations.

Check it out







The post Collective #667 appeared first on Codrops.

Collective #663




25 Years of CSS

Eric Meyer remebers how CSS kicked off 25 years ago this month in a conference room in Paris, May 7th, 1996.

Read it









IcePanel

Design structured diagrams and link directly to your repos, folders and files.

Check it out



Handy.js

Handy makes defining and recognizing custom hand poses in WebXR a snap. It recognizes 100+ hand poses, including ASL finger spelling. Built on Three.js.

Check it out






Vandal

A browser extension that helps you navigate back in time without leaving your current tab.

Check it out


LightGallery

A lightweight, modular, JavaScript image and video lightbox gallery plugin. Available for React.js, Vue.js, Angular, and TypeScript.

Check it out








The post Collective #663 appeared first on Codrops.

Collective #657






Collective 657 item image

UNCUT

An open source typeface catalogue, focusing on somewhat contemporary type.

Check it out



Collective 657 item image

lofi.cafe

A curated selection of live lofi stations from YouTube, in a beautiful online player.

Check it out
















The post Collective #657 appeared first on Codrops.

Collective #643














Collective 643 item image

The Devil’s Albatross

Learn how to build an algorithmic layout that switches from two centered elements to a spaced-out flex layout. By Nils Binder.

Read it






Collective 643 item image

Fire ball 2

Yoichi Kobayashi’s sketch that is an example of how to use SkinnedMesh, Skeleton, and Bone by creating a fireball tail.

Check it out



Collective 643 item image

Fantasy UIs

If you didn’t know about it: super interesting interviews about fantasy user interfaces.

Check it out






Collective 643 item image

LinkAce

LinkAce is a free and open source bookmark archive for long-term storage and organization of your favorite links.

Check it out




The post Collective #643 appeared first on Codrops.

Collective #615




Collective 615 item image

Primo

Primo is an all-in-one IDE, CMS, component library, and static site generator.

Check it out




Collective 615 item image

3D Hands gestures

An amazing free 3D hands gestures library with 12 hands gestures in 9 different skin tones and with 3 sleeve types.

Check it out











Collective 615 item image

css-media-vars

A brand new way to write responsive CSS. Named breakpoints, DRY selectors, no scripts, no builds, vanilla CSS.

Check it out









The post Collective #615 appeared first on Codrops.

Common CSS Issues For Front-End Projects

Common CSS Issues For Front-End Projects

Common CSS Issues For Front-End Projects

Ahmad Shadeed

When implementing a user interface in a browser, it’s good to minimize those differences and issues wherever you can, so that the UI is predictable. Keeping track of all of those differences is hard, so I’ve put together a list of common issues, with their solutions, as a handy reference guide for when you’re working on a new project.

Let’s begin.

1. Reset The Backgrounds Of button And input Elements

When adding a button, reset its background, or else it will look different across browsers. In the example below, the same button is shown in Chrome and in Safari. The latter adds a default gray background.

(Large preview)

Resetting the background will solve this issue:

button {
  appearance: none;
  background: transparent;
  /* Other styles */
}

See the Pen Button and Inputs by Ahmad Shadeed (@shadeed) on CodePen.

2. Overflow: scroll vs. auto

To limit the height of an element and allow the user to scroll within it, add overflow: scroll-y. This will look good in Chrome on macOS. However, on Chrome Windows, the scroll bar is always there (even if the content is short). This is because scroll-y will show a scroll bar regardless of the content, whereas overflow: auto will show a scroll bar only when needed.

Left: Chrome on macOS. Right: Chrome on Windows. (Large preview)
.element {
    height: 300px;
    overflow-y: auto;
}

See the Pen overflow-y by Ahmad Shadeed (@shadeed) on CodePen.

3. Add flex-wrap

Make an element behave as a flex container simply by adding display: flex. However, when the screen size shrinks, the browser will display a horizontal scroll bar in case flex-wrap is not added.

<div class="wrapper">
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
</div>
.wrapper {
  display: flex;
}

.item {
  flex: 0 0 120px;
  height: 100px;
}

The example above will work great on big screens. On mobile, the browser will show a horizontal scroll bar.

Left: A horizontal scroll bar is shown, and the items aren’t wrapped. Right: The items are wrapped onto two rows. (Large preview)

The solution is quite easy. The wrapper should know that when space is not available, it should wrap the items.

.wrapper {
    display: flex;
    flex-wrap: wrap;
}

See the Pen flex-wrap by Ahmad Shadeed (@shadeed) on CodePen.

4. Don’t Use justify-content: space-between When The Number Of Flex Items Is Dynamic

When justify-content: space-between is applied to a flex container, it will distribute the elements and leave an equal amount of space between them. Our example has eight card items, and they look good. What if, for some reason, the number of items was seven? The second row of elements would look different than the first one.

The wrapper with eight items. (Large preview)
The wrapper with seven items. (Large preview)

See the Pen justify-content by Ahmad Shadeed (@shadeed) on CodePen.

In this case, using CSS grid would be more suitable.

When an article is being viewed on a mobile screen, a long word or inline link might cause a horizontal scroll bar to appear. Using CSS’ word-break will prevent that from happening.

Large preview
.article-content p {
    word-break: break-all;
}   
(Large preview)

Check out CSS-Tricks for the details.

6. Transparent Gradients

When adding gradient with a transparent start and end point, it will look black-ish in Safari. That's because Safari doesn’t recognize the keyword transparent. By substituting it with rgba(0, 0, 0, 0), it will work as expected. Note the below screenshot:

Top: Chrome 70. Bottom: Safari 12. (Large preview)
.section-hero {
  background: linear-gradient(transparent, #d7e0ef), #527ee0;
  /*Other styles*/
}

This should instead be:

.section-hero {
  background: linear-gradient(rgba(0, 0, 0,0), #d7e0ef), #527ee0;
  /*Other styles*/
}

7. The Misconception About The Difference Between auto-fit And auto-fill In CSS Grid

In CSS grid, the repeat function can create a responsive column layout without requiring the use of media queries. To achieve that, use either auto-fill or auto-fit.

.wrapper {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
}
(Large preview)

In short, auto-fill will arrange the columns without expanding their widths, whereas auto-fit will collapse them to zero width but only if you have empty columns. Sara Soueidan has written an excellent article on the topic.

8. Fixing Elements To The Top Of The Screen When The Viewport Is Not Tall Enough

If you fix an element to the top of the screen, what happens if the viewport is not tall enough? Simple: It will take up screen space, and, as a result, the vertical area available for the user to browse the website will be small and uncomfortable, which will detract from the experience.

@media (min-height: 500px) {
    .site-header {
        position: sticky;
        top: 0;
        /*other styles*/
    }
}

In the snippet above, we’re telling the browser to fix the header to the top only if the viewport’s height is equal to or greater than 500 pixels.

Also important: When you use position: sticky, it won’t work unless you specify the top property.

Large preview

See the Pen Vertical media queries: Fixed Header by Ahmad Shadeed (@shadeed) on CodePen.

9. Setting max-width For Images

When adding an image, define max-width: 100%, so that the image resizes when the screen is small. Otherwise, the browser will show a horizontal scroll bar.

img {
    max-width: 100%;
}

10. Using CSS Grid To Define main And aside Elements

CSS grid can be used to define the main and aside sections of a layout, which is a perfect use for grid. As a result, the aside section’s height will be equal to that of the main element, even if it’s empty.

To fix this, align the aside element to the start of its parent, so that its height doesn’t expand.

.wrapper {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-gap: 20px;
}

// align-self will tell the aside element to align itself with the start of its parent.
aside {
  grid-column: 1 / 4;
  grid-row: 1;
  align-self: start;
}

main {
  grid-column: 4 / 13;
}
(Large preview)

See the Pen main and aside by Ahmad Shadeed (@shadeed) on CodePen.

11. Adding fill To An SVG

Sometimes, while working with SVGs, fill won’t work as expected if the fill attribute has been added inline in the SVG. To solve this, either to remove the fill attribute from the SVG itself or override fill: color.

Take this example:

.some-icon {
    fill: #137cbf;
}

This won’t work if the SVG has an inline fill. It should be this instead:

.some-icon path {
    fill: #137cbf;
}

12. Working With Pseudo-Elements

I love to use pseudo-elements whenever I can. They provide us with a way to create fake elements, mostly for decorative purposes, without adding them to the HTML.

When working with them, the author might forget to do one of the following:

  • add the content: "" property,
  • set the width and height without defining the display property for it.

In the example below, we have a title with a badge as a pseudo-element. The content: "" property should be added. Also, the element should have display: inline-block set in order for the width and height to work as expected.

Large preview

13. The Weird Space When Using display: inline-block

Setting two or more elements to display: inline-block or display: inline will create a tiny space between each one. The space is added because the browser is interpreting the elements as words, and so it’s adding a character space between each one.

In the example below, each item has a space of 8px on the right side, but the tiny space caused by using display: inline-block is making it 12px, which is not the desired result.

li:not(:last-child) {
  margin-right: 8px;
}
(Large preview)

A simple fix for this is to set font-size: 0 on the parent element.

ul {
    font-size: 0;
}

li {
    font-size: 16px; /*The font size should be reassigned here because it will inherit `font-size: 0` from its parent.*/
}
(Large preview)

See the Pen Inline Block Spacing by Ahmad Shadeed (@shadeed) on CodePen.

14. Add for="ID" When Assigning A Label Element To An Input

When working with form elements, make sure that all label elements have an ID assigned to them. This will make them more accessible, and when they’re clicked, the associated input will get focus.

<label for="emailAddress">Email address:</label>
<input type="email" id="emailAddress">
Large preview

15. Fonts Not Working With Interactive HTML Elements

When assigning fonts to the whole document, they won’t be applied to elements such as input, button, select and textarea. They don’t inherit by default because the browser applies the default system font to them.

To fix this, assign the font property manually:

input, button, select, textarea {
  font-family: your-awesome-font-name;
}

16. Horizontal Scroll Bar

Some elements will cause a horizontal scroll bar to appear, due to the width of those elements.

The easiest way to find the cause of this issue is to use CSS outline. Addy Osmani has shared a very handy script that can be added to the browser console to outline every element on the page.

[].forEach.call($$("*"), function(a) {
  a.style.outline =
    "1px solid #" + (~~(Math.random() * (1 << 24))).toString(16);
});
(Large preview)

17. Compressed Or Stretched Images

When you resize an image in CSS, it could be compressed or stretched if the aspect ratio is not consistent with the width and height of the image.

The solution is simple: Use CSS’ object-fit. Its functionality is similar to that of background-size: cover for background images.

img {
    object-fit: cover;
}
(Large preview)

Using object-fit won’t be the perfect solution in all cases. Some images need to appear without cropping or resizing, and some platforms force the user to upload or crop an image at a defined size. For example, Dribbble accepts thumbnails uploads at 800 by 600 pixels.

18. Add The Correct type For input.

Use the correct type for an input field. This will enhance the user experience in mobile browsers and make it more accessible to users.

Here is some HTML:

<form action="">
  <p>
    <label for="name">Full name</label>
    <input type="text" id="name">
  </p>
  <p>
    <label for="email">Email</label>
    <input type="email" id="email">
  </p>
  <p>
    <label for="phone">Phone</label>
    <input type="tel" id="phone">
  </p>
</form>

This is how each input will look once it’s focused:

(Large preview)

19. Phone Numbers In RTL Layouts

When adding a phone number like + 972-123555777 in a right-to-left layout, the plus symbol will be positioned at the end of the number. To fix that, reassign the direction of the phone number.

p {
    direction: ltr;
}
(Large preview)

Conclusion

All of the issues mentioned here are among the most common ones I’ve faced in my front-end development work. My goal is to keep a list to check regularly while working on a web project.

Do you have an issue that you always face in CSS? Let us know in the comments!

Smashing Editorial (dm, ra, al, yk, il)