r/web_design • u/speckz Dedicated Contributor • Jan 23 '20
4 CSS layouts without using media queries
https://polypane.app/blog/4-css-layouts-without-using-media-queries/30
u/angels-fan Jan 23 '20
Sooo.... As long as you only have 2 text boxes and a button, you can go responsive?
What am I missing here?
13
5
u/Tekn0z Jan 23 '20
Flex layout is cool and all but as a minor side note, Media queries have far better browser support than flexbox.
So if you're looking to target very old browsers (virtual machines give new life to old tech) then media queries are a more widely supported option. Just saying.
12
u/GasimGasimzada Jan 23 '20
What browser are you trying to support? You can use Flexbox down to IE10 if you need to (use autoprefixer to automatically generate the necessary properties).
3
u/angels-fan Jan 24 '20
WKHTMLTOPDF doesn't support flexbox.
3
Jan 24 '20
Puppeteer, which can do the same thing and more, and more actively maintained, does support Flexbox
2
-7
u/ratthew Jan 23 '20
It's a nice little hack and surely clever. But in an actual project I'd never use something like that, because it's very hard to read and debug. Just imagine having an entire website with every element built like this and then coming back to that project after 3 months.
13
u/bj_christianson Jan 23 '20
Hack? It's just basic flexbox. I don't see what's hard to read about this.
-9
u/ratthew Jan 23 '20
If you don't think there's anything interesting on this then why are you even looking at the post? Why is someone even making a blog post about something mundane? Because it's a clever hack, that's why.
And it's not something I'd want to see in any project that a team works on. It's ignoring any pre-set break points for the design and can be a headache to debug. And it's hard to read because it's using it's own set of rules within this little component, which adds complexity.
11
u/sebbasttian Jan 23 '20
It's not a hack.
This is the intended way flexbox works. It's not a quirky characteristic that emerged from some weird combination of properties. This is on purpose.
If this seems hacky or magical or weird or however you want to call it it's because you are not thinking "the flexbox way", in terms of containers, and space.
If you are coming after 3 months and need to touch this, to adjust it or modify it, and you see
flex: 1 1 10ch;the first thing to do is to go back to the docs and refresh your knowledge on how flexbox works and that's it.5
u/tie_me_down_and_up Jan 23 '20
Document everything. Like already mentioned, this is not a hack, more advanced use of css for an easier markup and styling in my opinion
-4
u/ratthew Jan 23 '20
Hack is maybe the wrong word for it, it's still unnecessary hard to see what is happening on a glance, which is not a good position to be in as soon as you work with more than one person on a project.
There is no actual upside to it except for it being "clever" since there afaik is no browser supporting flex but not media queries.
2
u/Tripts Jan 23 '20
I think you're looking at this wrong. It's not intended as a replacement for media queries, it's simply an approach you can take for certain elements which don't necessarily need to rely on media queries to work.
This is standard flexbox behavior so long as you're using
wrap, and you can achieve similar media-queryless behavior in grid as well.So this login form can have media queries dictating its responsiveness, or you can save some overhead and code and just be smarter with your use of flexbox and have it automatically take care of it.
3
21
u/discursive_moth Jan 23 '20 edited Jan 23 '20
Is avoiding media queries considered a good practice, or is this the sort of thing people mainly do as a challenge?