I seem to be observing some confusing behavior with flexbox, specifically when attempting to use align-self: baseline
. The basic issue is that it simply doesn’t work; the following snippet demonstrates the problem:
.flex-form {
display: flex;
}
.flex-form label {
align-self: baseline;
}
input[type=text] {
border: 1px solid black;
font-size: 16px;
margin: 0 10px;
padding: 5px;
}
button {
background-color: white;
border: 1px solid black;
margin: 0;
}
<form class="flex-form">
<label>Label: </label>
<input type="text" placeholder=" " />
<button type="submit">Submit</button>
</form>
Here’s a screenshot of what the output looks like:
As you can see, the label’s baseline is not aligned with the other form elements, despite having align-self: baseline
set. If I use align-items: baseline
on the parent container, however, I get a different result:
.flex-form {
display: flex;
align-items: baseline;
}
input[type=text] {
border: 1px solid black;
font-size: 16px;
margin: 0 10px;
padding: 5px;
}
button {
align-self: stretch;
background-color: white;
border: 1px solid black;
margin: 0;
}
<form class="flex-form">
<label>Label: </label>
<input type="text" placeholder=" " />
<button type="submit">Submit</button>
</form>
Is this correct behavior according to the spec, or is it a bug? If so, why? Is there a workaround? For reference, I’ve tested on Chrome 54, Safari 9.1.2, and Firefox 50 on macOS 10.11.6, and they all seem to exhibit the same results.