Live data from Hacker News

Absolute Horizontal And Vertical Centering In CSS

coding.smashingmagazine.com

31–40 of 62 posts

Re: Absolute Horizontal And Vertical Centering In CSS

#31
Good grief, if the element to be centered has a fixed height and width, then there's nothing to this. I've been using the negative margin method for years:

http://jsfiddle.net/mBBJM/2155/

Not that it's any less Stockholm-Syndrome-y than the linked article's solution, but still, I have no clue why this is on the front page of HN.

Re: Absolute Horizontal And Vertical Centering In CSS

#33
post #6

The fact that this is an interesting article is a huge indictment of CSS. It was developed for a different, simpler use case, and it's obviously the wrong abstraction at this point. Too bad it's entrenched.

I've been saying this of JS/HTML/CSS for years, but people seem to suffer from severe stockholm syndrome.

What do you suppose we do about it? Like it or not, people use web browsers to access the Internet, and as long as web browsers render HTML and CSS, we have to use the tools we have.

Re: Absolute Horizontal And Vertical Centering In CSS

#34
post #2

Vertical centering isn't that useful when you already have to know the height of things... I mean, if you already know the heights, you can just put the numbers in straight. The best way to do real vertical-centering that works with variable heights, and doesn't use JavaScript, is to take advantage of the fact that table cells do this with "vertical-align: middle". Inexplicably, only table cells allow true vertical c…

I actually did this just last week, wound up having to use a table cell with valign='middle' and felt both ashamed and proud at the same time.

Re: Absolute Horizontal And Vertical Centering In CSS

#35
post #29
post #19

Earlier quoted context omitted.

CSS is not great for its original use case. It was poorly designed by a group of people who chose to ignore existing understanding of layout models. The TeX boxes+glue model, had it been adapted for CSS, would have made all the absurdities and nasty layout workarounds of the last 20 years unnecessary.

> It was poorly designed by a group of people who chose to ignore existing understanding of layout models. Can you please elaborate how tables were the understanding of layout models 15 years ago? The web was not thought to be interactive at that era, but to be printed, it's not the fault of the old specs that the web progressed significantly fast.

Who said the web was designed to be printed?

(1) The "H" in HTML stands for hypertext. (2) When has a web page ever printed well?

Re: Absolute Horizontal And Vertical Centering In CSS

#36
post #27
post #19

Earlier quoted context omitted.

CSS is not great for its original use case. It was poorly designed by a group of people who chose to ignore existing understanding of layout models. The TeX boxes+glue model, had it been adapted for CSS, would have made all the absurdities and nasty layout workarounds of the last 20 years unnecessary.

I like to point to the failure of keeping table headers visible at the top of a page as you scroll down a table. If I had a book where a table spanned multiple pages and the header row wasn't included at the top of the page, I would throw the book out. A scrollable table with fixed headers is something that Visual Basic supported in 1997.

Unsurprisingly people have been trying to get browsers to support for that for years and years e.g. http://lists.w3.org/Archives/Public/www-style/2002May/0153.h...

Of course it wasn't a use case of interest to the mighty browser vendor cabal so it has never been considered a priority. It does seem like it will be possible soon though with position:sticky https://air.mozilla.org/intern-presentation-ford/

We should probably prepare some sacrifice to the browser vendor gods to thank them for this small morsel they have thrown us.

Re: Absolute Horizontal And Vertical Centering In CSS

#37
post #19
post #13

Earlier quoted context omitted.

Do you have a better suggestion? I agree with your frustration about this article being newsworthy (it's 2013! How are we still figuring out vertical centering?!), though I would argue that CSS is great for its original use case and certainly has its place today. Why is it bad that CSS is entrenched in the Web? Like any development technology, CSS has a learning curve and has several shortcomings (like vertical posit…

CSS is not great for its original use case. It was poorly designed by a group of people who chose to ignore existing understanding of layout models. The TeX boxes+glue model, had it been adapted for CSS, would have made all the absurdities and nasty layout workarounds of the last 20 years unnecessary.

Please read Håkon Wium Lie's PhD thesis http://people.opera.com/howcome/2006/phd/ to understand the reasoning behind the development of CSS. I think it was going in the right direction, although the ride got bumpy when committees and commercial interests started getting involved. Its major objective was to achieve separation of content from presentation which it achieved and I think you being unfair in your statement about CSS not being great for its original use case.

CSS did borrow concepts from TeX at the time. I agree with you that if it had borrowed more from TeX maybe we would have avoided Javascript and also we would have benefited from an updated model for TeX and I said so at http://tex.stackexchange.com/a/6463/963.

Maybe is time to revisit and revamp both.

Re: Absolute Horizontal And Vertical Centering In CSS

#38
post #6

The fact that this is an interesting article is a huge indictment of CSS. It was developed for a different, simpler use case, and it's obviously the wrong abstraction at this point. Too bad it's entrenched.

I used to think that as well, until I tried to implement the equivalent of variable text in an iOS TableView.

CSS makes life much, much easier.

Re: Absolute Horizontal And Vertical Centering In CSS

#39
post #33

Earlier quoted context omitted.

I've been saying this of JS/HTML/CSS for years, but people seem to suffer from severe stockholm syndrome.

What do you suppose we do about it? Like it or not, people use web browsers to access the Internet, and as long as web browsers render HTML and CSS, we have to use the tools we have.

My complaint is that a lot of people like CSS/HTML/JS. Because they have learned it and gotten comfortable with it. They don't know/understand anything else and their identity and sense of self-worth is challenged if you speak ill of these technologies. That's a big problem.

Pragmatically: I suppose that we embrace CSS/HTML/JS as object code. And I mean this in a much more dramatic way than CoffeeScript or SASS. This is finally starting to happen, thanks to browser support for things like source-maps. This is one reason I contribute to ClojureScript!

Idealistically: We should be pushing for lower level platforms for code distribution and execution, as well as host platform integration. Portable Native Client and similar efforts shouldn't be so controversial.

Re: Absolute Horizontal And Vertical Centering In CSS

#40
post #6

The fact that this is an interesting article is a huge indictment of CSS. It was developed for a different, simpler use case, and it's obviously the wrong abstraction at this point. Too bad it's entrenched.

I've been saying this of JS/HTML/CSS for years, but people seem to suffer from severe stockholm syndrome.

There have been attempts to fix this by creating languages which compile to each of those: HAML for HTML, CoffeeScript/Dart for JS, SASS/LESS for CSS. The language benefits tend to be fairly obvious, but there hasn't been much of anything in the way of native browser adoption that I've seen yet, apart from Google's plans for Chrome & Dart.
Post reply on HN