2016-10-01 11 views
2

ラベルを使用してチェックマークを表示しようとしています。ラベルを押すと、チェックマークがチェックされますが、ページの他の部分を押すと、自分の意図ではないチェックマークもチェックされます。ラベル全体にチェックマークを付ける

私は本当になぜこれが当てはまるのかわかりません。それを説明し、それを修正する方法を説明できますか?

header { 
 
    height: 100vh; 
 
    background-size: cover; 
 
    background-position: center; 
 
    margin-bottom: 50px; 
 
    display: flex; 
 
    flex-direction: column; 
 
    justify-content: center; 
 
    align-items: center; 
 
    text-align: center; 
 
    text-transform: uppercase; 
 
    color: black; 
 
} 
 
h1 { 
 
    font-size: 50px; 
 
    letter-spacing: 8px; 
 
} 
 
ul { 
 
    list-style-type: none; 
 
    margin-left: 0px; 
 
    padding-left: 0px; 
 
} 
 
p { 
 
    width: 600px; 
 
    margin: 0 auto 20px; 
 
} 
 
body { 
 
    margin-top: 0px; 
 
    margin-right: 0px; 
 
    margin-bottom: 0px; 
 
    margin-left: 0px 
 
} 
 
.container { 
 
    margin: auto; 
 
    width: 80%; 
 
} 
 
.page-content { 
 
    position: relative; 
 
    z-index: 0; 
 
    transition-duration: 0.4s; 
 
} 
 
.sidebar { 
 
    position: fixed; 
 
    top: 0px; 
 
    left: -180px; 
 
    right: 0; 
 
    bottom: 0px; 
 
    width: 120px; 
 
    padding: 30px; 
 
    background-color: black; 
 
    z-index: 0; 
 
    width: 120px; 
 
    transition-duration: 0.4s; 
 
} 
 
.sidebar a { 
 
    text-decoration: none; 
 
    opacity: 0.8; 
 
    font-family: monospace; 
 
    font-size: 25px; 
 
} 
 
.sidebar li { 
 
    margin-bottom: 15px; 
 
} 
 
.sidebar a:hover { 
 
    opacity: 1; 
 
} 
 
.toggle { 
 
    position: fixed; 
 
    top: 20px; 
 
    right: 0; 
 
    bottom: 0; 
 
    left: 20px; 
 
    z-index: 1; 
 
    color: black; 
 
    transition-duration: 0.4s; 
 
} 
 
#sidebartoggler:checked + .page-wrap .sidebar { 
 
    left: 0px; 
 
} 
 
#sidebartoggler:checked + .page-wrap .toggle { 
 
    left: 200px; 
 
} 
 
#sidebartoggler:checked + .page-wrap .page-content { 
 
    padding-left: 180px; 
 
}
<!doctype html> 
 
<html lang="en"> 
 

 
<head> 
 
    <meta charset="UTF-8"> 
 
    <meta name="description" content="A page about me"> 
 
    <meta name="keywords" content="web developer, projects"> 
 
    <meta name="author" content="Tristan Trouwen"> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
 

 

 
    <title>hello - Tristan Trouwen</title> 
 

 

 
    <!-- own style sheet --> 
 
    <link rel="stylesheet" href="/static/css/style.css"> 
 
    <!-- favicon --> 
 
    <link rel='icon' href="/static/assets/favicon.ico"> 
 
    <!-- google icons --> 
 
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> 
 
    <!-- the icon font --> 
 
    <link href="https://fonts.googleapis.com/css?family=Inconsolata" rel="stylesheet"> 
 

 
</head> 
 

 
<body> 
 

 

 

 
    <input type="checkbox" id="sidebartoggler" name="" value=""> 
 

 
    <div class="page-wrap"> 
 

 
    <label for="sidebartoggler"><i class="material-icons md-36 toggle">menu</i> 
 
    </label> 
 

 

 
    <div class="page-content"> 
 

 

 
     <header> 
 
     <h1>title</h1> 
 

 
     </header> 
 

 
    </div> 
 

 
    <div class="sidebar"> 
 

 
     <ul> 
 
     <li><a href="/index">home</a> 
 
     </li> 
 
     <li><a href="/shoutbox">shoutbox</a> 
 
     </li> 
 
     <li><a href="/resume">resume</a> 
 
     </li> 
 
     <li><a href="/projects">projects</a> 
 
     </li> 
 
     </ul> 
 

 
    </div> 
 
    </div> 
 

 

 

 
</body> 
 

 
</html>

+1

削除を削除 '.toggle {右:0。下:0; } ' –

+0

@MarekJanoudあなたが答えをしたら、私はそれを受け入れるでしょう。または、あなたがしなかった理由があります。 –

答えて

1

.toggle { right: 0; bottom: 0; }

関連する問題