News for hackers. Stuff that matters.
Re:CSS is unnecessary given a layout language by ChrisGaudreau on Thursday July 03, 2014 @09:08PM (#7986758)
I actually like CSS as it is now, and it's getting better (cough, flexbox). Am I the only one who finds CSS incredibly hard to master, though? I've been writing CSS for years and I still feel like a newbie sometimes, and feel like I'm just tinkering with random attributes until it looks right.
Re:CSS is unnecessary given a layout language by drcode on Thursday July 03, 2014 @09:37PM (#7986830)
Suppose you want to create the largest possible square div inside the rectangle of another div. Any layout language that can't let me satisfy such a simple and obvious layout constraint is a travesty.

CSS will not let you do this, even with flexbox.

Re:CSS is unnecessary given a layout language by girvo on Thursday July 03, 2014 @10:15PM (#7986946)
Re:CSS is unnecessary given a layout language by drcode on Friday July 04, 2014 @12:22AM (#7987329)
Does GSS work with Reactjs? If so, I might give it a try.
Re:CSS is unnecessary given a layout language by mercer on Friday July 04, 2014 @05:57PM (#7990340)
If GSS doesn't touch the markup, I think it would.
Re:CSS is unnecessary given a layout language by timdorr on Thursday July 03, 2014 @10:56PM (#7987089)
Huh? Flexbox will certainly let you do this: http://plnkr.co/edit/taXhuM4tetbNTlaKyjDr?p=preview (you shouldn't see any of the red box, just the green box)

Am I misinterpreting what you mean?

Re:CSS is unnecessary given a layout language by ars on Thursday July 03, 2014 @11:52PM (#7987256)
> Am I misinterpreting what you mean?

Yes. The red one should be a rectangle and the green one a square. In your case the red one is also a square.

Re:CSS is unnecessary given a layout language by Lerc on Thursday July 03, 2014 @10:05PM (#7986911)
Has anyone assembled a list of things such as this that CSS cannot do?

FlexBox always felt like it was a direct response to a few specific cases rather than a generalized gain in flexibility.

Re:CSS is unnecessary given a layout language by DougWebb on Thursday July 03, 2014 @10:47PM (#7987060)
I'm pretty sure FlexBox solves the "Why the hell can't I center these things vertically relative to one another?!?" problem that CSS has had for a very long time. Unfortunately, that wasn't the only problem CSS has had. Now we have to wait for CSS Grids, which look awesome and all, but based on history (floats, positioning, inline-blocks, flexbox) I'm not getting my hopes up that Grids will finally make CSS layouts reasonably adequate. (I'm not even raising the bar to 'usable'.)
Re:CSS is unnecessary given a layout language by scotty79 on Friday July 04, 2014 @02:33PM (#7989764)
Flexbox also doesn't interoperate with grids very well. Also can't lay out elements that are not siblings.
Re:CSS is unnecessary given a layout language by reillyse on Friday July 04, 2014 @02:40AM (#7987631)
agreed. I've been coding for 20+ years now (shit I feel old), 15 or so years of them with HTML and friends and I still throw my hands up in the air every so often when trying to deal with something as simple as getting stuff to show in the right place on a web page. CSS really is hard to master.

Part of that could just be me. I don't really care how it works, I just figure out the smallest amount possible to get what I'm doing to work and leave it at that. Maybe it's the fact that there are many ways to do very similar things, e.g. I can access an element by id or class or another attribute and so I just really need to find one that works and move on to other more "important" parts of the app.

Re:CSS is unnecessary given a layout language by mercer on Friday July 04, 2014 @05:58PM (#7990343)
In some cases I've just given up and decided to use javascript to control the position and size of elements...
Re:CSS is unnecessary given a layout language by notduncansmith on Thursday July 03, 2014 @11:13PM (#7987141)
I don't mean to be rude[0], but what do you find so difficult about it? The box model makes a lot of sense, and once you understand that you're most of the way there. I still Google for less-common syntax (e.g. adding a strikethrough style to text) from time to time, but most of it is internalized by now[1]. Code School[2] was great when I was first ramping up as a developer.

I do also have a great memory[4] for tiny, usually-trivial bits of data like: "no matter the z-index of an element, it cannot overlap an absolutely positioned element (with z-index greater than 0) unless it is also absolutely positioned". It doesn't feel like it's any different than remembering various bits of syntax or APIs, but maybe that's a more difficult thing for some people to remember than others - IANAN[3].

Give Code School a shot (go through the whole CSS Cross-Country course). You can get a 2-day free trial here: https://www.codeschool.com/hall_passes/213f3fedb6b9/claim_sh....

[0] I actually started writing this comment ~15 times before settling on an opening.

[1] It's mostly just abbreviations now: I don't think or speak (or type) "background-color", I just think "bgc<tab>". This is due to the fantastic Emmet plugin for Sublime: http://docs.emmet.io/css-abbreviations/

[2] https://www.codeschool.com/

[2a] You might be specifically interested in https://www.codeschool.com/courses/css-cross-country

[2b] I also have an affiliate link if you're feeling generous: http://mbsy.co/7djLz

[3] I am not a neurologist

[4] Terrible short-term memory though - my wife constantly complains about how I can remember "all those coding things" but can't recall what she asked me to do <30 seconds ago.

Re:CSS is unnecessary given a layout language by underwater on Friday July 04, 2014 @12:18AM (#7987318)
The motivations behind CSS are good. And the implementation is OK for the most part. But the "usually-trivial bits of data" are examples of it's failings. Let's talk examples:

* You want to overlay a <div> to the bottom write of a container. You can use "position: absolute; bottom: 0; right: 0", but that puts it at the bottom of the page instead. You have to add "position: relative" to the container. Understanding why you'd need this property means understanding implementation details. Which defeats the purpose of being a declarative language.

* You want to float a <aside> to the right of an <article> another. Just add "float: right", to the <aside> right? Whoops, that doesn't work. You'll need to add "overflow: hidden" to the <article> as well. Why should the overflow mode (which really should affect a node's contents) affect the layout of a sibling?

* You have a <header> element which extends the width of a content column. You want it to stay fixed within the page so give it "position: fixed". Now all of a sudden it's forgotten how wide it should be and shrinks to the width of it's content.

* You have a second <header> element with "width: 100%". You make it fixed too. Instead of retaining it's original width -- or shrinking like the other header -- it extends from its original position on the x-axis off the side of the screen so that it's 100% of the width of the page.

Sure, you can learn all of these special rules, but that isn't really a productive use of your time. I work with React a lot, so the approach we use is to create generic layout components that can do all of this stuff in a consistent way.

Re:CSS is unnecessary given a layout language by mercer on Friday July 04, 2014 @06:03PM (#7990352)
I'm fascinated that some people here express having no trouble with CSS. I'm inclined to think it's either inexperience with more complex layout, and otherwise just a completely different approach to CSS.

Could you perhaps show some examples of websites that you have built (or send me a message privately if you're not comfortable with that)?

One explanation I can think of is that the more willing you are to stray from the 'separation of content from presentation' rule, the easier things are. Many of the CSS problems I run into would be much easier to solve if I could allow my markup to be informed by the styling, rather than the other way around.

Another possibility is that some of the people who 'like' CSS are also the ones designing the site. They might design with their CSS knowledge as a basis.

In contrast, many of us who struggle with CSS probably struggle more because 1) we try to keep the html 'pure', and 2) we are handed designs by others or don't let ourselves be constrained by our knowledge of CSS.

Just some thoughts...

Re:CSS is unnecessary given a layout language by rorykoehein on Friday July 04, 2014 @06:19AM (#7988113)
> "no matter the z-index of an element, it cannot overlap an absolutely positioned element (with z-index greater than 0) unless it is also absolutely positioned"

FYI: this is incorrect. https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Under...

Re:CSS is unnecessary given a layout language by philbarr on Friday July 04, 2014 @08:15AM (#7988444)
> my wife constantly complains about how I can remember "all those coding things" but can't recall what she asked me to do <30 seconds ago.

This happens to me all the time. I thought about maybe writing an app that records all the time and then will play you back the last 30 seconds when you press a button.

Probably too resource intensive to be usable though.

Re:CSS is unnecessary given a layout language by taternuts on Thursday July 03, 2014 @09:19PM (#7986785)
> I've been writing CSS for years and I still feel like a newbie sometimes, and feel like I'm just tinkering with random attributes until it looks right.

This is exactly how I work with CSS too. Not surprisingly, it's my least favorite aspect of web development.

Re:CSS is unnecessary given a layout language by nawitus on Friday July 04, 2014 @09:24AM (#7988635)
This is how everyone I know works like, myself included.
Re:CSS is unnecessary given a layout language by ArtDev on Friday July 04, 2014 @07:45PM (#7990580)
Just like programming, a lot of time can be spent debugging. Also, just like programming, the more systematic your approach, the less time you will spend debugging.

The solution is to stay DRY by applying OOCSS/SMACSS/BEM concepts using Sass/Less.

Re:CSS is unnecessary given a layout language by goldenkey on Friday July 04, 2014 @10:34PM (#7990848)
It's the properties of CSS, and browser quirks that make CSS a pain. Not the ordering and markdown of files.
Re:CSS is unnecessary given a layout language by Kequc on Thursday July 03, 2014 @09:24PM (#7986797)
For example. I've just found out about flexbox where up until now I thought I'd finally mastered position relative/absolute and floats in order to get nearly everything that I want.
Re:CSS is unnecessary given a layout language by undozen on Thursday July 03, 2014 @09:15PM (#7986771)
I think you are not alone.
Re:CSS is unnecessary given a layout language by benburton on Thursday July 03, 2014 @09:31PM (#7986818)
Re:CSS is unnecessary given a layout language by colordrops on Thursday July 03, 2014 @09:46PM (#7986862)
First meme I've ever seen on hacker news. Please stop.
Re:CSS is unnecessary given a layout language by andrewflnr on Friday July 04, 2014 @01:07PM (#7989510)
Personally, I'm okay with a few hacker memes on Hacker News.
Re:CSS is unnecessary given a layout language by slowmotiony on Friday July 04, 2014 @05:12AM (#7987930)
Oh come on, it was funny.