I was learning a simple effect in front of the video, but I found a magical phenomenon. Sometimes elements automatically wrap.
link:
Code and effect
as shown in the figure
typecheckboxinput:
my question is that each of these four input has a label tag wrapped around it, but I just set the width of the label tag to 110px, and the value of is not large . Why does break the line when can obviously be lined up ?
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
*{
margin: 0;
padding: 0;
}
.container{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
text-align: center;
}
h1{
margin-bottom: 40px;
font-family: sans-serif;
}
.switch{
position: relative;
display: inline-block;
width: 110px;
height: 60px;
margin: 0 10px;
}
</style>
</head>
<body>
<div class="container">
<h1>Toggle Switch</h1>
<label class="switch">
<input type="checkbox">
<span class="slider"></span>
</label>
<label class="switch">
<input type="checkbox" checked>
<span class="slider"></span>
</label>
<label class="switch">
<input type="checkbox">
<span class="slider"></span>
</label>
<label class="switch">
<input type="checkbox" checked>
<span class="slider"></span>
</label>
</div>
</body>
</html>