You’ve probably heard the phrase “learn to fail or fail to learn.” The idea that making mistakes is essential to success has almost become clichéd by now. But in this talk, Zoe is prepared to embarrass herself with tales of her web design screw-ups to prove just how important and powerful it truly is to make mistakes in our work. Along the way, you’ll learn CSS tips and tricks that Zoe learned the hard way so that you don’t repeat her mistakes. Go out, try new things with CSS, and make new mistakes of your very own!
This talk was given at beyond tellerrand // BERLIN 2014, 5 November 2014
5. Books
Stunning CSS3: A Project-based Guide to the Latest in CSS
www.stunningcss3.com
Flexible Web Design: Creating Liquid and Elastic Layouts with CSS
www.flexiblewebbook.com
20. If you walk around with the idea that there are some people who are so gifted—they have these wonderful things in their head, but you’re not one of them, you’re just sort of a normal person, you could never do anything like that— then you live a different kind of life.
Brian Eno
21. Innovation requires a mindset that rejects the fear of failure and replaces that fear of failure with the joy of exploration and experimental learning.
Dr. Edward D. Hess
22. We also need to accept and embrace the concept of failure, not because failure is a good thing but because it’s a natural part of the path of progress. If you’re failing, at least that means you’re trying — not remaining on the outside of the arena, looking in.
Helen Walters
30. Using flex to control width/height
.flex-item {
flex: 1 0 100px;
}
flex-grow
flex-shrink
flex-basis
31. Defining the flex property
flex-grow
how much flex item will grow relative to other items if extra space is available (proportion of extra space that it gets)
flex-shrink
how much item will shrink relative to others if there is not enough space (proportion of overflow that gets shaved off)
flex-basis
the initial starting size before free space is distributed (any standard width/height value, including auto)
32. My first attempt
.component {
flex: 1;
}
.action {
flex: 1 1 100%;
}
Zoe’s Brain Said:
“Since .action starts out at 100%, it won’t have space to sit on the first line with the content preceding it, and will wrap to a second line.”
34. This fixed it
.component {
flex: 1;
margin-right: 1px;
}
35. /* this is needed to make .action wrap to second line. why??? */
My comment on the 1px margin
36. The hidden flex-basis value
.component {
flex: 1 1 0px;
}
.action {
flex: 1 1 100%;
}
Reality:
Since it’s fine for each .component to shrink to only 0px wide, a 100% wide element can and will sit on the same line as all the components.
37. That’s why margin “fixed” it
.component {
flex: 1;
margin-right: 1px;
}
.action {
flex: 1 1 100%;
}
What’s happening:
Now each .component starts out taking up 1px of space, so a 100% wide element can’t and won’t sit on the same line with any of the components.
38. Fixing flex-basis to force the wrap
.component {
flex: 1 1 200px;
}
.action {
flex: 1 1 100%;
}
Fixed:
.action will always wrap to new line, and .component boxes will wrap to additional lines when there’s less space than their combined flex-basis values (plus margin, etc.).
39. This was not just a case of succeeding despite a mistake. It was a case of succeeding because of a mistake.
41. flex can be proportional
Setting flex-grow/flex-shrink to different values can make flex items size themselves relative to each other
flex: 1;
flex: 1;
flex: 2;
42. Trying to make one twice as wide
.gallery-item {
flex: 1 0 200px;
}
.feature {
flex: 2 0 200px;
}
45. What I figured out
Having widths be in multiples of each other only works if flex-basis is 0
flex: 1 0 0px;
flex: 1 0 0px;
flex: 2 0 0px;
46. If flex-basis isn’t 0px…
…the widths may not end up as you expect
The third box gets twice as much of the extra, but that doesn’t make it twice as wide overall
flex: 1 0 10px;
flex: 1 0 10px;
flex: 2 0 10px;
10px + 5px extra = 15px
10px + 5px extra = 15px
10px + 10px extra = 20px
if 50px available
59. The 3 axes
X horizontal, left-right
Y vertical, up-down
Z away-towards you
A helpful diagram: your hand.
Photo: http://www.smashingmagazine.com/2012/01/06/adventures-in-the-third-dimension-css-3-d-transforms/
60. Or, if your hand is effed up:
http://architecture.gtu.ge/MPL/Multimodal%20Explorer/Acad_11/14control_workplane0/control_workplane.htm
61. Rotate around the axis not in the direction of the axis
As explained well by Peter Gasston in http://www.smashingmagazine.com/2012/01/06/adventures- in-the-third-dimension-css-3-d-transforms/
85. I needed CSS classes to:
1.Hide content visually and aurally
2.Hide just the text of an element, not whole element, but keep text spoken
3.Hide whole element visually but keep its text spoken by screen readers
97. Now that I understood what overflow did, I could decide if I needed it.
98. How I fixed my mistake
•Removed overflow:hidden from new instances going forward (but sadly not fixed in existing style sheets)
•Updated documentation to advise adding it on as-needed basis
99. (By the way, this FF/NVDA bug seems to be gone now.)
104. Vulnerability is the birthplace of innovation, creativity, and change. To create is to make something that has never existed before. There's nothing more vulnerable than that.
Dr. Brené Brown
108. /* this is needed to make .action wrap to second line. why??? */
109. The evidence in the comments
// Dear future me. Please forgive me. // I can't even begin to express how sorry I am.
// I am not sure if we need this, but too scared to delete.
// Magic. Do not touch.
110. Revisiting comments
// TODO: Fix this. Fix what?
// somedev1 - 6/7/02 Adding temporary tracking of Login screen // somedev2 - 5/22/07 Temporary my ass
111.
112. 99% of the population of the world doesn’t know CSS.
Zoe’s made-up statistic