loading...
markdown guide
 

I use flex in all my projects, but i had a trouble these days, i was making an header with tree elements, so i had this:

when i set: justify-content: space-between the logo was misaligned because is smaller than so it was necessary to align the with position absolute and trasnform to center it exactly in the header.

 

Interesting! I would love to see a codepen demo if you are willing to create one.

 

Take a look at this pen: codepen.io/joaoskr/pen/eYmPNBG

If you remove this properties from domain-toggle class, you'll see what i said about alignment:
position: absolute;
left: 50%;
transform: translateX(-50%);

That's a nice use case for position alignment. I think it would be difficult to achieve that result with any other method.

 

It depends on

  • How many items horizontally need to be aligned
  • If i want the content to center while ignoring other elements in the container
  • If I want the content to take the container width into account.
  • If I expect the number of elements to change.
  • If I want the padding to be factored into the alignment of the items.
 

Nice scenarios! Can you also specify solution method you use in each case? That would be great to know.

 

I mostly still use them because I struggle to get things right with flex and grid and fall back to old things I know 😓

 

Ah, the lazy arse solution fallback, when you don't care to fix your flex/grid errors. 😅

 

I am sure you can get it right, shouldn't be that hard for you to grasp the concept of flex and grid.

P.S Never had i imagined you'll be replying to my question. You made my day 😊

 

Animating items is sometimes easier with absolutely positioned elements

 

Because flex is quite buggy on old IE, and unfortunately a lot of my work has to be compatible with IE...

 
Classic DEV Post from May 29 '19

Is generalization killing creativity in the software industry?

As software gets more and more integrated into our lives, the industrialization of its crafting process becomes inevitable. But the over-generalization of software engineering can be crushing the creative side of programming.

dandup profile image
Frontend Dev.

Still haven't created a profile?

DEV is open source, committed to the open web, and quickly becoming the biggest world's biggest network of software developers.

Get started now ❤️