这是我正在制作的CSS滑块,但我无法找到出错的地方。它应该在点击汉堡包菜单时滑过然后显示内容。我哪里做错了?如何显示菜单的内容?我的z索引都错了吗?
h1 {
margin-top: 10px;
font-family: 'Reenie Beanie', cursive;
margin-bottom: 50px;
color: #0AEEFA;
font-size: 99px;
text-align: center;
margin-left: 25%;
}
h1:hover {
color: #ff0dbf;
}
img {
width: 60%;
padding-bottom: 80px;
}
#left{
position: relative;
width: 20%;
float: left;
border-style: none;
border-width: 5px;
border-color: #40E0D0;
padding-top: 150px;
}
#name {display: none;}
p {
display: inline;
margin-left: 20px;
font-family: 'Open Sans', cursive;
font-size: 11px;
color: #ff0dbf;
}
p:hover {
background-color: #FFA07A;
color: blue;
}
#place {display: none;}
#right{
width: 78%;
float: left;
margin: 0;
padding-top: 150px;
}
#sounds {display: none;}
#topnav {
width: 100%;
height: 50px;
margin: 0 auto;
position: fixed;
top: 0;
bottom: 100%;
left: 0;
}
ul {
margin: 0;
list-style-type:none;
text-align: center;
}
#container {
min-width: 100%;
min-height: 100%;
background-color: white;
position: relative;
top: 0;
bottom: 100%;
left: 0;
z-index: 1;
padding: 4em;
background-image: linear-gradient(135deg,
rgb(254,255,255) 0%,
rgb(221,241,249) 35%,
rgb(160,216,239) 100%);
background-size: 200%;
}
.navigation {
list-style: none;
background: #111;
width: 100%;
height: 100%;
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 0;
}
.nav-trigger {
position: absolute;
clip: rect(0, 0, 0, 0);
}
label[for="nav-trigger"] {
position: fixed;
top: 15px;
left: 15px;
z-index: 2;
width: 30px;
height: 30px;
cursor: pointer;
background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' x='0px' y='0px' width='30px' height='30px' viewBox='0 0 30 30' enable-background='new 0 0 30 30' xml:space='preserve'><rect width='30' height='6'/><rect y='24' width='30' height='6'/><rect y='12' width='30' height='6'/></svg>");
background-size: contain;
}
.nav-trigger:checked + label {
left: 215px;
}
.nav-trigger:checked ~ .container {
left: 200px;
box-shadow: 0 0 5px 5px rgba(0,0,0,0.5);
}
.nav-trigger + label, .container {
transition: left 0.2s;
}
body {
overflow-x: hidden;
}
.nav-item {
width: 200px;
border-top: 1px solid #111;
border-bottom: 1px solid #000;
}
.nav-item a {
display: block;
padding: 1em;
background: linear-gradient(135deg, rgba(0,0,0,0) 0%,rgba(0,0,0,0.65) 100%);
color: white;
font-size: 1.2em;
text-decoration: none;
transition: color 0.2s, background 0.5s;
}
.nav-item a:hover {
color: #c74438;
background: linear-gradient(135deg, rgba(0,0,0,0) 0%,rgba(75,20,20,0.65) 100%);
}
*,*:before,*:after{
-webkit-box-sizing:border-box;
-moz-box-sizing:border-box;
box-sizing:border-box;
margin:0;
padding:0;
}
html, body { height: 100%; width: 100%; font-family: Helvetica, Arial, sans-serif; }
&#13;
<ul class="navigation">
<li class="nav-item"><a href="#">Home</a></li>
<li class="nav-item"><a href="#">Portfolio</a></li>
<li class="nav-item"><a href="#">About</a></li>
<li class="nav-item"><a href="#">Blog</a></li>
<li class="nav-item"><a href="#">Contact</a></li>
</ul>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger"></label>
<div id="container">
<div id="topnav">
<h1>photos</h1>
</div>
<div id="left"><P>Hello for looking at my pictures</P>
<ul>
<li>
<P>Some are good</P>
</li>
<li>
<P>Some are better</P>
</li>
<li>
<P>Occassionally bad</P>
</li>
<li>
<P>(end of list)</P>
</li>
</ul>
</div>
<div id="right">
<ul>
<li class = "first"><a href="Slide01.jpg" data-lightbox="image-1"</a> <img src="P1010821.jpg"></li><p id= "name"></a>Chris Gage, <p id ="place"><em>Chinatown somewhere -time</p></em><p id="sounds">shazam!</p>
<li><a href="Slide02.jpg" data-lightbox="image-2"</a> <img src="P1010807.jpg"></li><p id= "name"></a>Chris Gage, <em><p id ="place">Tattoo joint; the owner's a rat</p></em><p id="sounds">kerrrpow!</p>
<li><a href="Slide03.jpg" data-lightbox="image-2"</a> <img src="P1010777.jpg"></li><p id= "name"></a>Chris Gage, <em><p id ="place">Turck [sic] bumper</p></em><p id="sounds">thwack!</p>
<li><a href="Slide04.jpg" data-lightbox="image-2"</a> <img src="P1010821.jpg"></li><p id= "name"></a>Chris Gage, <em><p id ="place">Tote things, sir</p></em><p id="sounds">zap!</p>
<li><a href="Slide05.jpg" data-lightbox="image-2"</a> <img src="P1010444.jpg"></li><p id= "name"></a>Chris Gage, <em><p id ="place">This one I call colorful</p></em><p id="sounds">ooof!</p>
<li><a href="Slide06.jpg" data-lightbox="image-2"</a><img src="P1010474.jpg"></li><p id= "name"></a>Chris Gage, <em><p id ="place">Color part II</p></em><p id="sounds">whammy pow!</p>
<li><a href="Slide07.jpg" data-lightbox="image-2"</a><img src="P1010482.jpg"></li><p id= "name"></a>Chris Gage, <em><p id ="place">Bride-to-be</p></em><p id="sounds">zing blast!</p>
<li><a href="Slide08.jpg" data-lightbox="image-2"</a><img src="P1010500.jpg"></li><p id= "name"></a>Chris Gage, <em><p id ="place">We got along famously</p></em><p id="sounds">grrr argh!</p>
<li><a href="Slide09.jpg" data-lightbox="image-2"</a><img src="P1010505.jpg"></li><p id= "name"></a>Chris Gage, <em><p id ="place">Okay, not too famously</p></em><p id="sounds">womp bam!</p>
<li><a href="Slide10.jpg" data-lightbox="image-2"</a><img src="P1010927.jpg"></li><p id= "name"></a>Chris Gage, <em><p id ="place">Saw red, said nothing</p></em><p id="sounds">slap punch kick!</p>
</ul>
</div>
</div>
&#13;
答案 0 :(得分:1)
好像你有很多重复的ID。在HTML,CSS和JavaScript中,重复的ID并不能很好地工作。如果要将样式添加到多个元素,则应使用类。我建议使用CSS高级选择器来制作纯滑块。我没有具体的答案,但请看http://www.w3schools.com/cssref/css_selectors.asp