I've been playing around with the flexbox properties to see what they can do:
- display: flex;
- flex-grow: n;
- align-items: center;
- justify-content: center;
However I've run into some unexpected behavior, and I'm hoping someone here can clarify for me. Manipulate one of the following properties of a flex-positioned element on the hover pseudo-selector:
- text-size
- font-weight
- text-shadow
The elements' relative weights appear to be remeasured, so the elements' positions jump around. If you repeatedly hover back and forth between the top two or bottom two elements, you can reduce their weights to essentially zero. A jsfiddle to illustrate:
https://jsfiddle.net/b8bjv70f/8/
(And one with twice as many items: https://jsfiddle.net/b8bjv70f/9/)
And the corresponding code:
[HTML]
<div class="container">
<div class="item one">
<a href="#">Item 1</a>
</div>
<div class="item two">
<a href="#">Item 2</a>
</div>
<div class="item three">
<a href="#">Item 3</a>
</div>
</div>
[CSS]
div.container {
position: absolute;
top: 0; bottom: 0; left: 0; right: 0;
/* */
display: flex;
flex-direction: column;
justify-content: center;
}
div.item {
background-color: rgbA(0, 0, 0, 0.05); outline: 1px solid white;
/* */
display: flex;
flex-grow: 1;
align-items: center;
justify-content: center;
}
div.item a {
padding: 1em 2em;
font-family: 'sans-serif'; font-size: 1em;
text-transform: uppercase; text-decoration: none;
color: rgbA(150, 150, 150, 1.00); background-color: rgbA(255, 255, 255, 1.00); outline: 1px solid white;
}
div.one a:hover { text-shadow: 0 0 1em black; }
div.two a:hover { font-weight: bold; }
div.three a:hover { font-size: 1.5em; }