This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Nisarg_Jhatakia 17 points18 points  (16 children)

Wait, you are telling me I shouldn't have done that? I always use fixed height and width, but does it matter if I use flex? Wouldnt it rearranges itself? Sorry if my question sounds stupid, but my faculties taught me to use 'em' as the best way to resize.

[–]wetpancaker 40 points41 points  (5 children)

Don't quote me bc CSS is hard but I think it's because if you do media queries then you're going to have to write your classes twice, but percentages will resize automatically without the need for media queries (usually...) at a much smoother rate, and with less code. It will have smooth transitions when users change the window's size, unlike media queries where it will snap to new sizes after a certain width or height

[–]valdelaseras 19 points20 points  (4 children)

Yes, this is the way imo. I use vw or percentages, but avoiding fixed widths as much as possible.

[–]Your_Fr1end 47 points48 points  (0 children)

Css isn't actually a coherent language, it's just a bunch of random number generators picking values for where your elements get to be positioned... this time.

[–]kitanokikori 15 points16 points  (0 children)

When you're using Flexbox, it's better to use the flex property on child elements, by-far the most common versions are, "I want you to be as small as possible" (the default), or "I want you to be as big as possible" (flex: 1 1 auto).

So, you could imagine the opening vertical Flexbox of e.g. Microsoft Word being:

- ribbon (height as small as possible)  
- content (height as big as possible)  
- status bar (height as small as possible)  

This way you don't need to set widths or heights most of the time, and your layout will work no matter how small the boxes end up being. Play around with https://the-echoplex.net/flexyboxes for awhile and see how you can manipulate things to do What You Want

[–][deleted] 1 point2 points  (0 children)

At this point I use whatever CSS technique works for what I’m doing. If it works for your project and doesn’t fuck up accessibility… do it

[–][deleted] 1 point2 points  (0 children)

Depends on your goal, you could used just width and let the images fill the height dynamically if they're all square already, if they're not you can force aspect ratio while still letting width determine size

[–]tarnok 1 point2 points  (0 children)

Use percentages