html - How to make different sections in a single page (explanation inside) -
basically i'm trying achieve making 1 pager website. there index page, and, example, if clicks on "services" send them services page. "services" page display 5 or 6 services, in 1 page. when user clicks on navigation item, scrolls using jquery div information displayed.
now don't want user see section below 1 he's / she's reading. example have service called edition , conception. if i'm reading "edition" section, don't want see "conception" right now, unless scroll it. first thought using margins, mean if i'm on 1024x768 display margin not same 1920x1080.
so basically, i'm looking way display content services on 1 page, each different service displayed so, unless visitor scrolls, next section under not seen.
hope makes sense, , support , help!
well, you'd need define navigation bar class, , class used store each section of page. setting height of section 100% ensure section takes entire height of user's screen. note works when height both html , body set 100% well.
set nav position fixed on screen, , use links call javascript function navigates correct section based on id of link.
html:
<nav> <a class="nav" id="1" href="#">section 1</a> <a class="nav" id="2" href="#">section 2</a> <a class="nav" id="3" href="#">section 3</a> </nav> <div class="section" id="1"> section 1 </div> <div class="section" id="2"> section 2 </div> <div class="section" id="3"> section 3 </div> css:
a { margin: 0 10px 0 10px; text-decoration: none; color: black; } html { height: 100%; } body { margin: 0; padding: 0; height: 100%; } nav { position: fixed; width: 100%; background-color: lightgrey; text-align: center; margin-bottom: 20px; } .section { height: 100%; padding-top: 20px; } js:
$('.nav').click(function() { var id = $(this).attr('id'); $('html, body').animate({ scrolltop: ($('#' + id + '.section').offset().top) }, 1000); }); demo:
hope looking for.
Comments
Post a Comment