I am trying to show two switches in a Sidenav
, with labels of different length. Here is my original version, without trying to align the switches:
<html>
<head>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/css/materialize.min.css">
</head>
<body>
<ul id="slide-out" class="sidenav">
<li><a>
Label
<span class="switch">
<label>
<input type="checkbox"></input>
<span class="lever"></span>
</label>
</span>
</a></li>
<li><a>
Long long label
<span class="switch">
<label>
<input type="checkbox"></input>
<span class="lever"></span>
</label>
</span>
</a></li>
</ul>
<script>
document.addEventListener('DOMContentLoaded', function() {
M.Sidenav.init(document.querySelectorAll(".sidenav"), { edge: "right" })[0].open();
});
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/js/materialize.min.js"></script>
</body>
</html>
This renders exactly as expected, with the two switches appearing horizontally wherever the labels end:
I thought I could fix this by adding the right
class to the switches, i.e. changing both <span class="switch">
to <span class="switch right">
; however, this then completely breaks the vertical alignment of
the switches:
What is the correct way of right-aligning these switch
es in a sidenav
?