Why are things so difficult in CSS? I want a box, with a toggle switch inside it, with text on either side that is vertically centered.
No matter what I try, the divs containing the text end up vertically staggered relative to the div containing the toggle switch.
I've read a dozen other SO questions about vertical centering...none of them seem to apply. Isn't there some operative principle here?
Fiddle: https://jsfiddle.net/cinerobert/h7g31bqa/
HTML:
<div id="div-yesnotoggle">
<div id="div-notext">No</div>
<div id="div-switch">
<label class="switch">
<input type="checkbox">
<div class="slider round"></div>
</label>
</div>
<div id="div-yestext">
Yes
</div>
</div>
CSS:
#div-yesnotoggle {
border: solid;
width: 160px;
display: inline-block;
}
#div-notext {
padding-top: 10px;
padding-bottom: 10px;
display: inline-block;
border: solid;
width: 40px;
}
#div-switch {
border: solid;
display: inline-block;
width: 60px;
}
#div-yestext {
padding-top: 10px;
padding-bottom: 10px;
display: inline-block;
border: solid;
}