一个页面滚动页脚不显示

问题描述 投票:2回答:3

我使用这个插件https://github.com/peachananr/onepage-scroll为我的投资组合。它工作正常,我有唯一的问题是,页脚不与我想要的高度显示(高度:150像素)。

<div class="main">
<div class="section">1</div>
<div class="section">2</div>
<div class="section">3</div>
<footer>Text</footer>
</div>

如果我添加类部分到页脚它可以工作,但它会使页脚高度100%。

我发现这可以解决这个问题的另一种插件http://alvarotrigo.com/fullPage/,但我不希望只是因为一个问题,改变它。

如果有人能帮助我解决这个问题,我将非常感激。

jquery css
3个回答
1
投票

我没有看到任何内置的方式做到这一点。你是否愿意修补插件?如果是这样,行之后:

$.fn.transformPage = function(settings, pos, index) {

加:

if (pos <= -(total - 1) * 100) {
    footer_height = sections.eq(-1).height();
    footer_percent = footer_height / $(this).height();
    pos = pos + 100 - (footer_percent * 100);
}

而关于CSS,假设您的页脚是.page3

.onepage-wrapper .section.page3 {
    height: 150px;
}

See it working


0
投票

你可以用这样的重要尝试在CSS:

footer {
 height: 150px !important;
} 

0
投票

如果功能:

this.moveDown = function(e) {

后:

if (i.loop == true) {
    pos = 0;
    r = document.querySelector(i.sectionContainer + "[data-index='1']");
  }

加:

   /*VM Cusom code for footer */
      else if(i.footer) {
        const footer = document.querySelector(i.footer);
        const footerHeight = footer.offsetHeight;
        const footerStyle = window.getComputedStyle(footer);
        const footerOuterHeight = footerHeight + parseInt(footerStyle.marginTop)  + parseInt(footerStyle.marginBottom);
        const footerPercent = footerOuterHeight / e.offsetHeight;
        if(pos >= ((t-1) * -100)){
          pos = pos - (footerPercent * 100);
          r = document.querySelector(i.sectionContainer + "[data-index='" + (parseInt(t)) + "']");
        }
        else {
          return;
        }
      }
    /*VM Cusom code for footer */

而在功能:

  this.moveUp = function(e) {

后:

if (!r) {
      if (i.loop == true) {
        pos = (u - 1) * 100 * -1;
        r = document.querySelector(
          i.sectionContainer + "[data-index='" + u + "']"
        );
      }
      else {
        return;
      }
    }

加:

else if(t == u && (pos < ((t-1) * -100))) {
  pos = (r.dataset.index) * 100 * -1;
  r = document.querySelector(
    i.sectionContainer + "[data-index='" + u + "']"
  );
}

在初始化加选择到您的页脚

onePageScroll(".home", { 
    footer: "footer" 
});
© www.soinside.com 2019 - 2024. All rights reserved.