javascript - 你如何制作一个滚动页面?

标签 javascript jquery html css

如何制作像 this 这样的单页滚动网站? . 我尝试使用来自 here 的“peachananr”插件但它没有用,反而弄乱了我的布局。 例如在做之后:

<div class="main">
<section id = "mainPage" class="container mainPage" >
</section>

<section id = "projectContents" class = " projectContents" >
<span style = "display: block; float: left; margin-top: 50px; font-size:40px; font-family: 'Alegreya Sans SC', sans-serif;">
 Projects:
</span>
</section>
</div>

我的整个页面都在一起了 o.O ! (所有部分合而为一)我的页面基本上是一个单页网站,如 this

这是我布局每个部分页面的方式的 CSS:

body, html {
  height: 100%;
  margin: 0;
}

* {
    box-sizing: border-box;
    /* look this up */
}

.container {
    width: 100%;
    text-align: center;
    height: 100%;
}


.mainPage {
height:100%;
width:100%;

background: url(Imgs/13.jpg);
background-repeat: no-repeat;
background-position: center center;

-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;

}

.projectContents {
position: relative;
height:100%;
width:100%;
background: white;

}

这是我的HTML:

<section id = "mainPage" class="container mainPage" >
</section>

<section id = "projectContents" class = " projectContents" >
<span style = "display: block; float: left; margin-top: 50px; font-size:40px; font-family: 'Alegreya Sans SC', sans-serif;">
 Projects:
</span>
</section>

请问我该如何解决这个问题,或者您能否提供任何解决方案。示例将不胜感激! :D 非常感谢!

ps 我在我的 js 文件中这样调用插件 $(".main").onepage_scroll();

This is what happens when i use the plugin

最佳答案

确保您正在加载 onepage-scroll css 和 javascript...它可以在没有任何 CSS 的情况下正常工作。那里的风格。

HTML

<div class="main">
<section id = "mainPage" class="container mainPage" >
</section>

<section id = "projectContents" class = " projectContents" >
<span style = "display: block; float: left; margin-top: 50px; font-size:40px; font-family: 'Alegreya Sans SC', sans-serif;">
 Projects:
</span>
</section>
</div>

JS

$('.main').onepage_scroll()  

DEMO

关于javascript - 你如何制作一个滚动页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22313220/

相关文章:

javascript - 由于某种原因,图像未在 IE 8 或 IE 9 中显示

javascript - 如何在Ajax中添加DIV标签

javascript - 使用 php 将登录用户从登录页面重定向到用户仪表板

javascript - 如何使用排序数组填充下拉菜单

jquery - 将 jQuery 的 ajax() 函数与 SSL 客户端证书结合使用

jquery - Genesis WordPress Sticky Footer 通过 CSS/jQuery

php - 向mysql数据库插入数据时出错

javascript - Jest - 监视嵌套的 promise (axios)

javascript - 从多个相同文本中查找选定的文本

html - 星星和幻灯片输入在 IE 浏览器中不起作用