Home >Web Front-end >JS Tutorial >Fullpage.js full screen scroll plug-in usage example
The company website has just been built, and through full-screen scrolling, the browsing experience of the official website has been significantly improved. So let’s summarize the methods of using fullpage.js. Corrections welcome
1. Introduction to fullpage.js
##fullpage.js is a set of js plug-ins that realize full-screen scrolling in browsers. Many websites now They are all used to achieve a better browsing experience. Possible functions:
•Multiple callback functions
•Support mobile phone and tablet touch events
•Support CSS3 animation
•Support window scaling
•Automatically adjust when window scaling
•Can set scroll width, background color, scroll speed, loop options, callbacks, text alignment, etc.
bower|bower install fullpage.js
github|https://github.com/alvarotrigo/fullPage.js/
cdn|https://cdnjs.com/libraries/fullPage.js
<link rel="stylesheet" href="css/jquery.fullPage.css"> <script src="js/jquery.min.js"></script> <script src="js/jquery.fullPage.js"></script>Note: jquery must be introduced first , and then introduce fullpage. When I first started writing the demo, the effect could not be achieved because of the wrong order. The browser reported an error that jquery in fullpage.js was undefined.
<div id="fullpage"> <div class="section">section1</div> <div class="section">section2</div> <div class="section">section3</div> <div class="section">section4</div> </div>All content is contained in the div with the ID name fullpage. You cannot add this to the body.
The div element with the class name .section is a single page. You can control the replacement between different pages through the mouse wheel and keyboard, and you can also set up list navigation.
At the same time, if you want to create a horizontal screen cutting effect within a page, you can add div.slide to div.section. The code is as follows:
<div class="section"> <div class="slide"> Slide 1 </div> <div class="slide"> Slide 2 </div> <div class="slide"> Slide 3 </div> <div class="slide"> Slide 4 </div> </div>5. Initialize fullpage
$(document).ready(function() { $('#fullpage').fullpage( { ....... //options 详情参看https://github.com/alvarotrigo/fullPage.js/ } ); });Set sidebar navigation
<ul id="myMenu"> <li data-menuanchor="firstPage" class="active"><a href="#firstPage">First section</a></li> <li data-menuanchor="secondPage"><a href="#secondPage">Second section</a></li> <li data-menuanchor="thirdPage"><a href="#thirdPage">Third section</a></li> <li data-menuanchor="fourthPage"><a href="#fourthPage">Fourth section</a></li> </ul>
#myMenu{ position:fixed; ... } $('#fullpage').fullpage({ anchors: ['firstPage', 'secondPage', 'thirdPage', 'fourthPage', 'lastPage'], menu: '#myMenu' });6. Problems encountered and solutions
Then I tried various solutions:
1.div.section
section{overflow:hidden}
After testing, this method is of no use.
Specific implementation method demo:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>无标题文档</title> <script language="javascript" type="text/javascript"> function showAllContent(status1,status2){ document.getElementByIdx("showContent").style.display=status1; document.getElementByIdx("showLoad").style.display=status2; } </script> </head> <body onLoad='showAllContent("","none")'> <div id="showLoad" style="z-index:2; display:block; width:auto; height:auto;">页面加载中......</div> <div id="showContent" style="z-index:1; "> //最终要显示的内容<br></div><br><script>showAllContent("none","");</script><br></body><br></html>The above is the entire content of this article. I hope it will be helpful to everyone's learning, and I also hope that everyone will support the PHP Chinese website. For more articles related to fullpage.js full-screen scrolling plug-in usage examples, please pay attention to the PHP Chinese website!