To solve the issue of z-index only working on positioned elements, what I do on all new projects is set the following: * { position:relative; } This does two things. Allows me to set z-index values without hassle, and also allows me to set top/bottom left/right values. Refer to my GitHub repo for the code for my base structure for new projects. https://github.com/garand/base
Do you use tables at all? What effect does this have on cells, rows, etc?
What No One Told You About Z-Index
51–60 of 100 posts
Re: What No One Told You About Z-Index
#52Don't we love CSS? it's so easy to do both complex things like 3D animations but also simple things like position something centered horizontally or vertically by just saying align:center, oh, sorry, it's margin: 0 auto, right, no? it's left:50% with a relative inside an absolute div, or was that an absolute div inside a relative span? ok so doing it vertically is really easy, it's valign:middle, oh, wait, I'm confus…
Does anyone have any insight as to why it is this way? To me it seems insane, but I don't trust my own judgement in domains like this because I've never built anything comparable. Are there really good reasons for CSS to be the way it is?
Re: What No One Told You About Z-Index
#53Earlier quoted context omitted.
Does anyone have any insight as to why it is this way? To me it seems insane, but I don't trust my own judgement in domains like this because I've never built anything comparable. Are there really good reasons for CSS to be the way it is?
Let's clarify the question. "Does anyone have any insight as to why vertical centering of dynamic-height content is the way it is?" Yes. The original standards committee created a layout model (block, inline, and inline-block elements) that (they felt) adequately balanced language complexity with features. It's easy to idiomatically achieve vertical centering. http://jsfiddle.net/aMMxj/10/ "Does anyone have any insig…
For example, i never had to read the spec for ruby to get jruby to work.
Re: What No One Told You About Z-Index
#54Earlier quoted context omitted.
I don't really want to add to the dogpile of comments explaining why you missed the point, but the blog post pretty clearly states what the criteria for the "challenge" were: "Here's the challenge: try to see if you can make the red element stack behind the blue and green elements without breaking any of the following rules: Do not alter the HTML markup in any way. Do not add/change the z-index property of any elemen…
He didn't change the markup. He changed the CSS. He didn't add a property to an element. He added a property to a rule.
Re: What No One Told You About Z-Index
#55Re: What No One Told You About Z-Index
#56Earlier quoted context omitted.
Does anyone have any insight as to why it is this way? To me it seems insane, but I don't trust my own judgement in domains like this because I've never built anything comparable. Are there really good reasons for CSS to be the way it is?
Let's clarify the question. "Does anyone have any insight as to why vertical centering of dynamic-height content is the way it is?" Yes. The original standards committee created a layout model (block, inline, and inline-block elements) that (they felt) adequately balanced language complexity with features. It's easy to idiomatically achieve vertical centering. http://jsfiddle.net/aMMxj/10/ "Does anyone have any insig…
that solution
1. only works for text, which is part of eranation's rant.
2. only works if you know the exact height of the container.
3. isn't even centered: http://i.imgur.com/lz8Mq.png
Re: What No One Told You About Z-Index
#57Earlier quoted context omitted.
It's a fact; look at this profile data for a simple test: http://minus.com/lyJrZzYj4bSoH The '*' selector shoots up the chart, and for some reason the browser lays down a lot more rules then when it's absent. 2ms is not much, but when complexity increases it all adds up (games, client-side apps, etc).
Take a look at this. http://paulirish.com/2012/box-sizing-border-box-ftw/ Specifically the Performance section.
Add a couple * selectors - one in the reset, one more in your base sheet - plus a couple descendant * selectors, global box-sizing/position rules and you've put a heavy saddle on the matching and rendering engine. It might not matter for 80% of websites, but you need to be aware of it.
Re: What No One Told You About Z-Index
#58Earlier quoted context omitted.
It's a fact; look at this profile data for a simple test: http://minus.com/lyJrZzYj4bSoH The '*' selector shoots up the chart, and for some reason the browser lays down a lot more rules then when it's absent. 2ms is not much, but when complexity increases it all adds up (games, client-side apps, etc).
Take a look at this. http://paulirish.com/2012/box-sizing-border-box-ftw/ Specifically the Performance section.
Re: What No One Told You About Z-Index
#59Earlier quoted context omitted.
Let's clarify the question. "Does anyone have any insight as to why vertical centering of dynamic-height content is the way it is?" Yes. The original standards committee created a layout model (block, inline, and inline-block elements) that (they felt) adequately balanced language complexity with features. It's easy to idiomatically achieve vertical centering. http://jsfiddle.net/aMMxj/10/ "Does anyone have any insig…
genuine question as a non front end engineer- do you recommend reading the CSS spec as a reference guide? im basically asking whether someone learning to be good in CSS should read the spec or pick up one of the recommended books (that appear from time to time on HN). For example, i never had to read the spec for ruby to get jruby to work.
Re: What No One Told You About Z-Index
#60Earlier quoted context omitted.
Does anyone have any insight as to why it is this way? To me it seems insane, but I don't trust my own judgement in domains like this because I've never built anything comparable. Are there really good reasons for CSS to be the way it is?
I don't have a reference for this, but I always got the impression that CSS was intentionally limited to help browsers implementers write efficient layout engines with as few pathological cases as possible. For instance, if you could specify the value of object attributes using arbitrary expressions with other objects' attributes as input, it would be very easy to have circular dependencies, unexpectedly high computa…