滚动时改变点

时间:2018-01-05 10:36:33

标签: javascript html sass

当我滚动时,我试图让我的网页上的点跟随页面的变化。现在,当我点击它时,我只能点亮页面。以下是我的代码。



$('.dot-nav--item').on('click', function() {
  $this = $(this),
    $siblings = $this.siblings();

  $this.addClass('is-active');
  $siblings.removeClass('is-active');
})

body {
  background-color: rgb(200, 200, 200);
  font-family: open sans;
  padding: 0;
  margin: 0;
}

.dot-nav {
  position: fixed;
  top: 50%;
  left: 95%;
  transform: translate(-50%, -50%);
  z-index: 99999;
}


/* Fin Init */

.dot-nav--item {
  position: relative;
  display: block;
  width: 16px;
  height: 16px;
  margin-bottom: 24px;
  border: 3px solid #fff;
  border-radius: 50%;
}

.dot-nav--item:before,
.dot-nav--item:after {
  content: "";
}

.dot-nav--item:before {
  position: absolute;
  top: -1px;
  bottom: -1px;
  left: -1px;
  right: -1px;
  transform: scale(0);
  opacity: 0;
  border-radius: 50%;
  background-color: #fff;
  transition: all .3s;
}

.dot-nav--item:after {
  display: block;
  width: 3px;
  height: 30px;
  margin: 16px auto 0;
  background-color: #fff;
}

.dot-nav--item:last-child:after {
  display: none;
}

.dot-nav--item:hover {
  cursor: pointer;
}

.dot-nav--item.is-active:before {
  opacity: 1;
  transform: scale(1);
}

.dot-nav--link {
  position: absolute;
  top: 50%;
  visibility: hidden;
  transform: translate(-120%, -50%);
  width: 200px;
  padding: 5px 10px;
  opacity: 0;
  color: #111;
  background-color: #fff;
  transition: all .3s;
}

.dot-nav--link:before {
  content: "";
  position: absolute;
  top: 50%;
  left: 100%;
  width: 0;
  height: 0;
  border-width: 6px 0 6px 8px;
  border-color: transparent transparent transparent #fff;
  border-style: solid;
  transform: translateY(-50%);
}

.dot-nav--item:hover .dot-nav--link {
  visibility: visible;
  opacity: 1;
  transform: translate(-110%, -50%);
}

#page0 {
  height: 80vw;
  background: url("smarthome.JPG") no-repeat top center fixed;
  background-size: cover;
  margin-bottom: -9em;
}

#page1 {
  height: 80vw;
  background: url("retail.JPG") no-repeat top center fixed;
  background-size: cover;
  margin-bottom: -9em;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div id="page0"></div>
<div id="page1"></div>

<nav class="dot-nav">
  <ul class="dot-nav--list list-unstyled">
    <li class="dot-nav--item is-active"><a href="readmore1.html#page0" class="dot-nav--link">Introduction</a></li>
    <li class="dot-nav--item"><a href="readmore1.html#page1" class="dot-nav--link">Smart Home</a></li>
  </ul>
</nav>
&#13;
&#13;
&#13;

当我滚动页面时,我不确定如何填充点,你有什么想法吗?提前谢谢。

0 个答案:

没有答案