Well, everything is in the question... I'm working on a login form that I would like to align vertically at the center of the body. I'm new to sass and compass, and I struggle to use the right mixin for this...
The html code is pretty simple:
<body>
<div>
A div of unknown height to be vertically centered.
</div>
</body>
This is the CSS3 code that would make it work:
<style>
html{
height:100%;
}
body{
height:100%;
display:flex;
align-items:center;
/* I spared all the compatibility properties for the different browsers */
}
</style>
___EDIT :
I came up to something like this, but I realized I misunderstood the way to use the parent selector with SASS:
div.ieVerticalCentered {
body.verticalCentering & {
height:100%;
display:-ms-flexbox;
display:-moz-box;
display:-webkit-box;
display:-webkit-flex;
display:flex;
-ms-align-items:center;
-moz-align-items:center;
-webkit-align-items:center;
align-items:center;
html.verticalCentering & {
height:100%;
}
}
}
Therefore, the core question is: is it possible to apply a specific style to a parent element when a child element has a specific class.
In my knowledge, it's not possible with static CSS, but could be done with JS. Having just discovered Sass, I was wondering if something nice could be considered...