【问题标题】:Make a navigation from footer to header on my website在我的网站上进行从页脚到页眉的导航
【发布时间】:2018-04-27 21:32:33
【问题描述】:

我想创建一个具有反向导航的网站。

您从从页脚开始,然后在网站末尾爬到页眉

如果可能的话,我只会使用 CSS 和 Javascript (jQuery)

我的代码结构:

<body>
    <div class="end"></div>
    <div class="middle"></div>
    <div class="start"></div>
</body>

【问题讨论】:

  • 你现在的问题是什么?
  • 所以基本上是一个登陆页面(Onepage),你从页面底部开始,当你访问它并且必须向上滚动?
  • 使用 flexbox 和 order,您可以将标记放在您想要的位置并更改顺序
  • 是的,就是这样!
  • 到目前为止你尝试了什么?

标签: javascript jquery html css web


【解决方案1】:

滚动到页面底部:

window.scrollTo(0, document.body.offsetHeight);

【讨论】:

    【解决方案2】:

    使用flex 父级,您可以更改元素的顺序或使用column-reverse Fiddle,正如@jcubic 在他的回答中所说,使用window.scrollTo(0, document.body.offsetHeight);,因此一旦页面加载,它将位于正文处底部。希望这会有所帮助。

    window.scrollTo(0, document.body.offsetHeight);
    html,body{margin: 0;}
    .flex{
      display: flex;
      flex-direction: column-reverse;
    }
    header{
      display: flex;
      justify-content: space-around;
      height: 150px;
      background-color: #a9a9a9;
      align-items: center;
    }
    
    nav{
      width: 30%;
    }
    
    nav ul{
      list-style: none;
      display: flex;
      justify-content: space-around;
      padding: 0;
      
     
    }
    
    nav ul li a{
      text-decoration: none;
      color: #000;
    }
    
    footer{
      background-color: #a9a9a9;
      display: flex;
      align-items: center;
      justify-content: center;
      height: 150px;
    }
    <div class="flex">
      <header>
      <div class="logo">
        <img src="http://placehold.it/88x88" alt="">
      </div>
        <nav>
          <ul>
            <li><a href="#">Menu 1</a></li>
            <li><a href="#">Menu 2</a></li>
            <li><a href="#">Menu 3</a></li>
            <li><a href="#">Menu 4</a></li>
          </ul>
        </nav>
      </header>
       <section>
        <h1>Content</h1>
        <h1>Content</h1>
        <h1>Content</h1>
        <h1>Content</h1>
        <h1>Content</h1>
        <h1>Content</h1>
        <h1>Content</h1>
        <h1>Content</h1>
        <h1>Content</h1>
      </section>
      <footer>
        footer content
      </footer>
    
    </div>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-09-28
      • 1970-01-01
      • 1970-01-01
      • 2015-03-13
      • 2014-09-29
      • 2019-02-18
      • 1970-01-01
      相关资源
      最近更新 更多