html - DIV show and hide with jumping to next when click on link -
i'm using css
& html
show/hide few div's. (http://jsfiddle.net/davidthomas/x8hmq/2/)
i extend code prev , next "buttons" is... if div2 visible , hit next button jump div3...
is possible css+html only?
#content > div { display: none; width: 50%; margin: 0 auto; } #content > div:target { display: block; } #content > div a.hide { display: block; text-align: right; }
<ul> <li><a href="#div1">div one</a> </li> <li><a href="#div2">div two</a> </li> <li><a href="#div3">div three</a> </li> <li><a href="#div4">div four</a> </li> <li><a href="#">hide</a> </li> </ul> <div id="content"> <div id="div1">this div one</div> <div id="div2">this div two</div> <div id="div3">this div three</div> <div id="div4">this div four</div> </div>
ul{ text-align: center; padding: 0; margin: 0 auto 20px; } li{ display: inline-block; border: 1px solid green; padding: 10px; } #content{ position: relative; max-width: 80%; margin: 0 auto; } .prev, .next, .dummy-right, .dummy-left{ box-sizing: border-box; border: 1px solid blue; padding: 10px; position: absolute; top: 0; height: 40px; width: 30px; } .prev, .dummy-left{ left: -30px; } .next, .dummy-right{ right: -30px; } .dummy-right, .dummy-left{ background: #fff; border-color: #fff; } #content > div { display: none; width: 50%; margin: 0 auto; padding: 20px; border: 1px solid red; } #content > div:target { display: block; } #content > div a.hide { display: block; text-align: right; }
<ul> <li><a href="#div1">div one</a> </li> <li><a href="#div2">div two</a> </li> <li><a href="#div3">div three</a> </li> <li><a href="#div4">div four</a> </li> <li><a href="#">hide</a> </li> </ul> <div id="content"> <a href="#div2" class="next">></a> <div id="div1"> div 1 <a href="#div2" class="next">></a> <span class="dummy-left"></span> </div> <div id="div2">this div 2 <a href="#div1" class="prev"><</a> <a href="#div3" class="next">></a> </div> <div id="div3">this div 3 <a href="#div2" class="prev"><</a> <a href="#div4" class="next">></a> </div> <div id="div4">this div 4 <a href="#div3" class="prev"><</a> <span class="dummy-right"></span> </div> </div>
Comments
Post a Comment