


Horizontal Responsive Page Sliding
To design a responsive page navigation similar to the provided image, consider the following jQuery solution:
- Calculate Dimensions: Determine the number of slides, set the wrapper width, and set each slide's width accordingly.
- Slide Animation: Bind a click event to navigation links that animates the wrapper's left-margin to reveal the corresponding slide.
- Active Link: Toggle the "selected" class for the clicked link to highlight the active page.
This approach ensures that the navigation adapts to screen size and handles pages with varying heights, eliminating gaps. Additionally, it utilizes a single menu occurrence to minimize markup and supports a dynamic number of slides.
<code class="js">$(document).ready(function () { var slideNum = $('.page').length, wrapperWidth = 100 * slideNum, slideWidth = 100 / slideNum; $('.wrapper').width(wrapperWidth + '%'); $('.page').width(slideWidth + '%'); $('a.scrollitem').click(function () { $('a.scrollitem').removeClass('selected'); $(this).addClass('selected'); var slideNumber = $($(this).attr('href')).index('.page'), margin = slideNumber * -100 + '%'; $('.wrapper').animate({ marginLeft: margin }, 1000); return false; }); });</code>
<code class="css">html, body { height: 100%; margin: 0; overflow-x: hidden; position: relative; } nav { position: absolute; top: 0; left: 0; height: 30px; } .wrapper { height: 100%; background: #263729; } .page { float: left; background: #992213; min-height: 100%; padding-top: 30px; } #page-1 { background: #0C717A; } #page-2 { background: #009900; } #page-3 { background: #0000FF; } a { color: #FFF; } a.selected { color: red; } .simulate { height: 2000px; }</code>
<code class="html"><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <div class="wrapper"> <nav> <a href="#page-1" class="scrollitem selected">page 1</a> <a href="#page-2" class="scrollitem">page 2</a> <a href="#page-3" class="scrollitem">page 3</a> </nav> <div id="page-1" class="page"> <h3 id="page">page 1</h3> <div class="simulate">Simulated content heigher than 100%</div> </div> <div id="page-2" class="page"> <h3 id="page">page 2</h3> <div class="simulate">Simulated content heigher than 100%</div> </div> <div id="page-3" class="page"> <h3 id="page">page 3</h3> <div class="simulate">Simulated content heigher than 100%</div> </div> </div></code>
The above is the detailed content of How can I create responsive horizontal page sliding using jQuery for a website with varying heights?. For more information, please follow other related articles on the PHP Chinese website!

There's been a run of tools, articles, and resources about color lately. Please allow me to close a few tabs by rounding them up here for your enjoyment.

Robin has covered this before, but I've heard some confusion about it in the past few weeks and saw another person take a stab at explaining it, and I wanted

I absolutely love the design of the Sandwich site. Among many beautiful features are these headlines with rainbow underlines that move as you scroll. It's not

Many popular resume designs are making the most of the available page space by laying sections out in a grid shape. Let’s use CSS Grid to create a layout that

Page reloads are a thing. Sometimes we refresh a page when we think it’s unresponsive, or believe that new content is available. Sometimes we’re just mad at

There is very little guidance on how to organize front-end applications in the world of React. (Just move files around until it “feels right,” lol). The truth

Most of the time you don’t really care about whether a user is actively engaged or temporarily inactive on your application. Inactive, meaning, perhaps they

Wufoo has always been great with integrations. They have integrations with specific apps, like Campaign Monitor, Mailchimp, and Typekit, but they also


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Zend Studio 13.0.1
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver CS6
Visual web development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.