1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
| <!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="Author" content="NoSmoking">
<meta name="DVP-discussion" content="d1967401">
<title>[CSS] Ouverture par la droite</title>
<style>
html, body {
margin: 0;
padding: 0;
min-height: 100vh;
font: 1em/1.5 Verdana,Arial,sans-serif;
}
body {
box-sizing: border-box;
border: 1px solid transparent;
}
.menu {
position: relative;
text-align: right;
padding-bottom: .5em;
}
.menu nav {
display: block;
position: absolute;
top: 100%;
right: 0;
Width: 0;
overflow: hidden;
text-align: center;
line-height: 2em;
white-space: nowrap;
background: #FFF;
box-shadow: 0 0 2px #000 inset;
transition: .5s all;
transform: translate3d(0,0,0);
}
.menu nav a {
display: block;
}
#hide-show-menu {
position: absolute;
left: -9999em;
}
#hide-show-menu ~ label {
display: inline-block;
margin: 0 1em;
padding: .5em;
border: 1px solid #CCC;
cursor: pointer;
}
#hide-show-menu:checked ~ nav {
width: 100%;
}
@media(min-width:640px) {
.menu nav {
display: inline-block;
top: 0;
left: 0;
width: 10em;
transition: none;
}
#hide-show-menu:checked ~ nav {
width: 10em;
}
#hide-show-menu ~ label {
display: none;
}
}
</style>
</head>
<body>
<main>
<header>
<h1>Ouverture menu par la droite</h1>
</header>
<section class="menu">
<input id="hide-show-menu" type="checkbox">
<label for="hide-show-menu">Show menu</label>
<nav>
<a href="http://xhtml.developpez.com/cours/">Cours (X)HTML</a>
<a href="http://css.developpez.com/cours/">Cours CSS</a>
<a href="http://javascript.developpez.com/cours/">Cours JS</a>
</nav>
</section>
</main>
</body>
</html> |
Partager