html - 我在创建导航幻灯片时遇到问题

标签 html css web

我正在尝试将幻灯片整合到我的导航中。 Here is the slide我正在尝试整合。

这是我正在处理的代码,网站是 rosannalui.com .我有点难过我做错了什么,任何帮助将不胜感激。太感谢了!

<html>
        <head>
            <title>Rosanna Lui</title>
            <link href="https://fonts.googleapis.com/css?family=Lora:400" rel="stylesheet">
            <link href="https://fonts.go``ogleapis.com/css?family=Montserrat:400,500" rel="stylesheet">
            <link href="style.css?v=1" rel="stylesheet">
            <meta name="viewport" content="width=700">
            <meta charset="utf-8">
            <meta name="viewport" content="width=device-width, initial-scale=1">
            <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
            <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
            <style>
          body {
              position: relative; 
          }
          #section1 {padding-top:50px;height:500px;color: #fff; background-color: #9E88E5;}
          #section2 {padding-top:50px;height:500px;color: #fff; background-color: #673ab7;}
          #section3 {padding-top:50px;height:500px;color: #fff; background-color: #ff9800;}
         </style>
        </head>


        ———

          <div class="container-fluid">

        ——
        <body class="bodyhome">


            <!-- Menu -->
        <nav class="navbar navbar-inverse navbar-fixed-top">
            <div class='container-fluid'>
        <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
                  <span class="icon-bar"></span>
                  <span class="icon-bar"></span>
                  <span class="icon-bar"></span>                        
              </button>
            </div>
            <div>
              <div class="collapse navbar-collapse" id="myNavbar">
                <ul class="nav navbar-nav">
                  <li><a class =“menuhello” href="#">Hello</a></li>
                  <li><a class =“menuwork” href=“#work”>Work</a></li>
                  <li><a class =“menucontact” href=“#contact”>Contact</a></li>
                </ul>
              </div>
            </div>
          </div>
        </nav>    

        <div id="section1" class="container-fluid">
          <!-- Hello -->
            <script src="https://cdn.jsdelivr.net/particles.js/2.0.0/particles.min.js"></script>
            <div id="hello" class="darkgray">
                <div id="hellotext">
                    <h1>I'm Rosanna, a visual and UX designer, and I am passionate about making <span class="bluetext">delightful</span> experiences.</h1>
                </div>
            </div>

            <!-- Dots -->
            <script>
                particlesJS.load('hello', 'particles.json', function() {
                    console.log('hello@rosannalui.com');
                });
            </script>
        </div>


        <div id="section2" class="container-fluid">
           <!-- Work -->
            <a name="work"></a>
            <div class="grid">
                <div class="work work1">
                    <a href="./bee/">
                        <h2>Bee Adventurous</h2>
                        <h3>Augmented Reality Game</h3>
                    </a>
                </div>
                <div class="work work2">
                    <a href="./husky">
                        <h2>Husky Checkout</h2>
                        <h3>Equipment Rental Application</h3>
                    </a>
                </div>
                <div class="work work3">
                    <a href="./chord">
                        <h2>Chordinate</h2>
                        <h3>Networking App for Musicians</h3>
                    </a>
                </div>
                <div class="work work4">
                    <a href="./design">
                        <h2>Design Work</h2>
                        <h3>Illustration and Design</h3>
                    </a>
                </div>
            </div>

        </div>

    <div id="section3" class="container-fluid">
       <!-- Contact -->
        <script src="https://cdn.jsdelivr.net/particles.js/2.0.0/particles.min.js"></script>
        <a name="contact"></a>
        <div class="lightgray contact content">
            <img src="images/rosanna.png" style="margin-top: -3vw" />
            <div>
                <h3>Rosanna Lui</h3>
                <p>
                    I am a recent Interactive Media Design graduate at the University of Washington. Inspired by my background as a daughter of immigrants, I believe that it is important to design with the user in mind and to create content that is accessible to everyone.
                    I am always looking for new projects and opportunities to collaborate with others.
                </p>
                <p>
                    Email me: <a href="mailto:hello@rosannalui.com">hello@rosannalui.com</a>
                </p>
            </div>
        </div>


    </div>


    <script>
    $(document).ready(function(){
      // Add scrollspy to <body>
      $('body').scrollspy({target: ".navbar", offset: 50});   

      // Add smooth scrolling on all links inside the navbar
      $("#myNavbar a").on('click', function(event) {
        // Make sure this.hash has a value before overriding default behavior
        if (this.hash !== "") {
          // Prevent default anchor click behavior
          event.preventDefault();

          // Store hash
          var hash = this.hash;

          // Using jQuery's animate() method to add smooth page scroll
          // The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area
          $('html, body').animate({
            scrollTop: $(hash).offset().top
          }, 800, function(){

            // Add hash (#) to URL when done scrolling (default click behavior)
            window.location.hash = hash;
          });
        }  // End if
      });
    });
    </script>


    </body>

    </html>

最佳答案

对于快速而肮脏的解决方案,请使用:

html{
  scroll-behavior: smooth;
}

请注意 not all browsers support this .

另一种快速方法是使用 jump.js .

把这个加到你的头上:

<script src="https://rawgit.com/jumpjs/jumpjs/master/dist/jumpjs.min.js"></script>

关于html - 我在创建导航幻灯片时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49440408/

相关文章:

java - 网站前端使用 JavaScript,后端使用 Java

javascript - Contenteditable 防止插入符号放置在某个元素之后

javascript - 在 <table> 中使用 <div> 有效吗?选择表格行内的所有选项

javascript - 如何在 javascript 中使用单选按钮显示值并使用复选框值添加它?

javascript - 如何使用 DoodleNerd 的 CSS 文本框提取文本?

php - 加载 AJAX 页面后调用 Javascript 函数

html - 为什么我的悬停命令不起作用?

html - 跨度在流体行中起作用

azure - Windows Azure 发布网站 - "Unable to get subscription information. An item with the same key has already been added"

html - 网站图标不会出现在任何移动或桌面浏览器上