Kaynağa Gözat

产品中心增加导航

gzb
guozhongbo 1 yıl önce
ebeveyn
işleme
572e05f5db
4 değiştirilmiş dosya ile 75 ekleme ve 25 silme
  1. 29
    1
      css/product.css
  2. 0
    15
      js/about.js
  3. 38
    2
      js/product.js
  4. 8
    7
      sections/product.html

+ 29
- 1
css/product.css Dosyayı Görüntüle

@@ -443,7 +443,10 @@
443 443
 .nav{
444 444
   position: fixed;
445 445
   top: 5rem;
446
-  left: 2rem;
446
+  left: 0.6rem;
447
+  border-radius: 0.08rem;
448
+    background: #ffffffff;
449
+    box-shadow: 1px 0 3px 0 #0000001a;
447 450
 }
448 451
 .nav>div{
449 452
   font-size: 0.14rem;
@@ -451,4 +454,29 @@
451 454
   color: white;
452 455
   color: #2d8cf0;
453 456
   line-height: 0.4rem;
457
+  width: 1.4rem;
458
+  border-bottom: 1px solid #f7f7f7f7 ;
459
+  cursor: pointer;
460
+}
461
+.nav div:first-of-type {
462
+  background-color: #298df0;
463
+  border-top-right-radius:0.08rem ;
464
+  border-top-left-radius: 0.08rem;
465
+  color: white;
466
+  border-bottom: 1px solid #298df0;
467
+}
468
+.nav div:last-of-type{
469
+  background-color: #298df0;
470
+    border-bottom-right-radius: 0.08rem;
471
+    border-bottom-left-radius: 0.08rem;
472
+    color: white;
473
+}
474
+.nav img{
475
+  width: 0.16rem;
476
+  height: 0.16rem;
477
+}
478
+.nav .active {
479
+  background-color: #298df0;
480
+  color: white;
481
+  border-bottom: 1px solid #298df0;
454 482
 }

+ 0
- 15
js/about.js Dosyayı Görüntüle

@@ -75,9 +75,6 @@ $(function () {
75 75
   var offsetpx = (datalist.length - len) * divwidth; //可偏移度
76 76
   var offleft = 0; //当前偏移量
77 77
   function animate(offset) {
78
-    if (datalist.length <= 5) {
79
-      return;
80
-    }
81 78
     var left = parseInt(list.css("left")) + offset;
82 79
     var absnum = Math.abs(offset);
83 80
     if (left < 0 - offsetpx) {
@@ -109,9 +106,6 @@ $(function () {
109 106
   }
110 107
   //点击高亮滚动
111 108
   function animates(offset) {
112
-    if (datalist.length <= 5) {
113
-      return;
114
-    }
115 109
     var left = parseInt(list.css("left")) + offset; //获取元素属性
116 110
     if (index < 6 && left >= 0) {
117 111
       list.animate({ left: 0 }, 300, function () {});
@@ -143,9 +137,6 @@ $(function () {
143 137
 
144 138
   // 鼠标离开图片区域时,轮播继续
145 139
   function play() {
146
-    if (datalist.length <= 5) {
147
-      return;
148
-    }
149 140
     timer = setTimeout(function () {
150 141
       next.trigger("click");
151 142
       play();
@@ -162,9 +153,6 @@ $(function () {
162 153
 
163 154
   // 右按钮点击事件
164 155
   next.bind("click", function () {
165
-    if (datalist.length <= 5) {
166
-      return;
167
-    }
168 156
     // 判断当前是否在动画
169 157
     if (list.is(":animated")) {
170 158
       return;
@@ -186,9 +174,6 @@ $(function () {
186 174
 
187 175
   // 左按钮事件
188 176
   prev.bind("click", function () {
189
-    if (datalist.length <= 5) {
190
-      return;
191
-    }
192 177
     // 判断当前是否在动画
193 178
     if (list.is(":animated")) {
194 179
       return;

+ 38
- 2
js/product.js Dosyayı Görüntüle

@@ -14,7 +14,7 @@ $(function () {
14 14
 
15 15
   function animate(offset) {
16 16
     var top = parseInt(list.css("top")) + offset;
17
-    console.log(list.css("top"));
17
+    // console.log(list.css("top"));
18 18
     var absnum = Math.abs(offset);
19 19
     index++;
20 20
 
@@ -30,7 +30,7 @@ $(function () {
30 30
       offset = 0;
31 31
     }
32 32
     showButton();
33
-    console.log("当前索引", index, top, offset);
33
+    // console.log("当前索引", index, top, offset);
34 34
     list.animate({ top: offset }, 300, function () {
35 35
       if (top > -200) {
36 36
       }
@@ -99,4 +99,40 @@ $(function () {
99 99
 
100 100
   play();
101 101
   showButton();
102
+
103
+  //楼梯导航
104
+  $(window).on("scroll", function () {
105
+    var $scroll = $(this).scrollTop();
106
+    // 拖动滚轮,点亮对应的楼层标签
107
+    $(".piece").each(function () {
108
+      var $stepTop = $(".piece").eq($(this).index()).offset().top;
109
+      // 楼层的top大于滚动条的距离
110
+      if ($stepTop > $scroll) {
111
+        $(".step").removeClass("active");
112
+        $(".step").eq($(this).index()).addClass("active");
113
+        // 中断循环
114
+        return false;
115
+      }
116
+    });
117
+  });
118
+
119
+  // 获取每个楼梯的offset().top,点击楼层让对应的内容模块移动到对应的位置
120
+  var $stepItem = $(".step");
121
+  $stepItem.on("click", function () {
122
+    $(this).addClass("active").siblings("li").removeClass("active");
123
+    var $stepTop = $(".piece")
124
+      .eq($(this).index() - 1)
125
+      .offset().top;
126
+    // 获取每个楼梯的offsetTop值
127
+    $("html,body").animate({
128
+      scrollTop: $stepTop
129
+    });
130
+  });
131
+
132
+  // 回到顶部
133
+  $(".top").on("click", function () {
134
+    $("html,body").animate({
135
+      scrollTop: 0
136
+    });
137
+  });
102 138
 });

+ 8
- 7
sections/product.html Dosyayı Görüntüle

@@ -370,13 +370,14 @@
370 370
     </div>
371 371
     <div class="nav">
372 372
       <div>导航</div>
373
-      <div>区域大数据平台</div>
374
-      <div>校园教学平台</div>
375
-      <div>考试及测评系统</div>
376
-      <div>网课平台</div>
377
-      <div>校本资源库</div>
378
-      <div>微课工具</div>
379
-      <div>
373
+      <div class="step">区域大数据平台</div>
374
+      <div class="step">校园教学平台</div>
375
+      <div class="step">考试及测评系统</div>
376
+      <div class="step">网课平台</div>
377
+      <div class="step">智慧教学系统</div>
378
+      <div class="step">校本资源库</div>
379
+      <div class="step">云鸽微课</div>
380
+      <div class="top">
380 381
         <img src="../img/product/top.png" />
381 382
       </div>
382 383
     </div>

Loading…
İptal
Kaydet