Live data from Hacker News

Things I wish I’d known about CSS

cssfordesigners.com

21–30 of 340 posts

Re: Things I wish I’d known about CSS

#21
post #17

Useful article. Getting started with CSS must be harder these days than it was 15-20 years ago. Not only for mobile-friendliness, but also because of the coexistence of flexbox/grid/traditional layouts. I'm wondering if the standard will ever been simplified, instead of being added more and more features.

Just use flexbox (and grid if you need to control both dimensions at once). You can ignore all of the old ways of doing layout. Flexbox is supported back to IE11.

Re: Things I wish I’d known about CSS

#22

> Using pixels (px) is tempting because they’re simple to understand: declare font-size: 24px and the text will be 24px. But that won’t provide a great user experience, particularly for users who resize content at the browser level or zoom into content. Pixels (px) in CSS are relative as well, and scale with zoom. What is the benefit of em/rem?

>What is the benefit of em/rem? They (em*) scale with the element's font size, and if you set an elements font-size itself in em, that will be relative to the parent element's font size. For example: body { font-size: 18px } .something { border: 0.1em solid black; } .something > .inner { font-size: 1.5em } If you change the font-size on body, everything on that page will re-scale seamlessly. This is most useful for t…

The challenge with em units is that if you modify a parent element's size it changes the children as well. In your example, if you put 'font-size: 2.0em' on the .something class then the .inner would end up changing to 3.0em. That's rarely what you actually want to happen (especially in a web app). If you just want to control the overall font scaling of everything on the page using rem is preferable, because then they'd ignore the parent and scale based on the root element size.

Re: Things I wish I’d known about CSS

#23
post #19

Anybody knows a good book on CSS for ppl with a solid programming background? Every couple of years I try something and fail. Somehow the tutorial rave about the cascading on and on, and when it comes how to strategically design a good SAP working on different devices the stuff gets mute quickly.

Not a book but https://developer.mozilla.org/en-US/docs/Web/CSS is my go-to for all things CSS, I love mdn it's a fabulous resource.

Also zeal (dash on Mac which is paid or you can build zeal yourself like I did) has docsets for CSS which are good.

Re: Things I wish I’d known about CSS

#25
post #8

Ends up to a page saying "The page you requested does not exist". ...which kinda reflects "things I wish about CSS", so 10/10.

Its loading here. Try again :-)

I know, I retried before and it worked.

But "it works differently every time I try" wouldn't have made a good CSS joke. Oh, wait.

Re: Things I wish I’d known about CSS

#26

I wish the author had gone a bit further into em vs rem. I'm reading other articles on the topic but they're simply technical explanations and I'm still not clear on what features of the page are best designed using em or rem.

Generally you want to use rem for setting the font-size of the elements and to controll overall spacing.

em is often used for the padding of elements. For example buttons that exist in different sizes.

Re: Things I wish I’d known about CSS

#27
post #17

Useful article. Getting started with CSS must be harder these days than it was 15-20 years ago. Not only for mobile-friendliness, but also because of the coexistence of flexbox/grid/traditional layouts. I'm wondering if the standard will ever been simplified, instead of being added more and more features.

https://xkcd.com/927/

Backwards compatibility support will always require adding on new ways to do things and not removing stuff.

I personally find flexboxes frustrating at times and tend to limit my usage to non-grid spacing (footer columns, horizontal menus) and responsive vertical alignment.

CSS grids are pretty cool, and maybe if you were just starting out it would be easier to pick up fresh than having to unlearn floating divs.

Funny thing is that if you go back 25 years (pre-table layout era), everything was not only mobile compatible but your target viewport was 800x600 which I find the painful part of mobile compatibility these days - it's that ugly zone in-between a nice mobile/cell phone layout and having the whole desktop to work with.

Re: Things I wish I’d known about CSS

#28

I’ve always thought of ch as a unit intended for monospaced fonts or languages with monospaced characters. Does anyone know of any other practical uses?

I personally feel it’s a good spacer between labels and form controls, icons and text and can also be useful for other inline-like elements that should have a natural spacing. Another possible use is in setting min and max widths for content areas where ideal line-length for comfort of reading is considered important.

Re: Things I wish I’d known about CSS

#30
post #17

Useful article. Getting started with CSS must be harder these days than it was 15-20 years ago. Not only for mobile-friendliness, but also because of the coexistence of flexbox/grid/traditional layouts. I'm wondering if the standard will ever been simplified, instead of being added more and more features.

I started around 2006 and there are definitively more standards — as in more ways to achieve the same thing. And yes, you have mobile — though we did fluid and "responsive" layouts back then as well.

One thing that is better is the browsers adherence to standards. I spent my first years learning all IE6 rendering bugs and how to overcome them.

Post reply on HN