炫酷的花式滑块滑动无缝切换特效

  • 个人网站:【 海拥】【小霸王游戏机】【大转盘】
  • 风趣幽默的前端学习课程:28个案例趣学前端
  • 想寻找共同学习交流、摸鱼划水的小伙伴,请点击【摸鱼学习群】【学习文档】
  • 免费且实用的计算机相关知识题库:进来逛逛

给大家安利一个免费且实用的前端刷题(面经大全)网站,点击跳转到网站。

在线演示地址:https://haiyong.site/moban/texiao/1/
源码下载地址:http://43.142.11.221/125/

✨ 项目基本结构

目录结构如下:

├── css
│   └── style.css
├── js
│   └── script.js
└── index.html

本节教程我会带大家使用 HTML 、CSS和 JS 来制作一个 炫酷的花式滑块滑动无缝切换特效

本节示例将会实现如下所示的效果:


下面让我们一起来实现吧!

HTML

HTML中内的代码:

<div class="demo-cont">
  
  <div class="fnc-slider example-slider">
    <div class="fnc-slider__slides">
      
      <div class="fnc-slide m--blend-green m--active-slide">
        <div class="fnc-slide__inner">
          <div class="fnc-slide__mask">
            <div class="fnc-slide__mask-inner">div>
          div>
          <div class="fnc-slide__content">
            <h2 class="fnc-slide__heading">
              <div class="fnc-slide__heading-line">
                <span>Blackspan>
              div>
              <div class="fnc-slide__heading-line">
                <span>Widowspan>
              div>
            h2>
            <button type="button" class="fnc-slide__action-btn">
              Credits
              <span data-text="Credits">Creditsspan>
            button>
          div>
        div>
      div>
      
      
      <div class="fnc-slide m--blend-dark">
        <div class="fnc-slide__inner">
          <div class="fnc-slide__mask">
            <div class="fnc-slide__mask-inner">div>
          div>
          <div class="fnc-slide__content">
            <h2 class="fnc-slide__heading">
              <div class="fnc-slide__heading-line">
                <span>Captainspan>
              div>
              <div class="fnc-slide__heading-line">
                <span>Americaspan>
              div>
            h2>
            <button type="button" class="fnc-slide__action-btn">
              Credits
              <span data-text="Credits">Creditsspan>
            button>
          div>
        div>
      div>
      
      
      <div class="fnc-slide m--blend-red">
        <div class="fnc-slide__inner">
          <div class="fnc-slide__mask">
            <div class="fnc-slide__mask-inner">div>
          div>
          <div class="fnc-slide__content">
            <h2 class="fnc-slide__heading">
              <div class="fnc-slide__heading-line">
                <span>Ironspan>
              div>
              <div class="fnc-slide__heading-line">
                <span>Manspan>
              div>
            h2>
            <button type="button" class="fnc-slide__action-btn">
              Credits
              <span data-text="Credits">Creditsspan>
            button>
          div>
        div>
      div>
      
      
      <div class="fnc-slide m--blend-blue">
        <div class="fnc-slide__inner">
          <div class="fnc-slide__mask">
            <div class="fnc-slide__mask-inner">div>
          div>
          <div class="fnc-slide__content">
            <h2 class="fnc-slide__heading">
              <div class="fnc-slide__heading-line">
                <span>Thorspan>
              div>
              <div class="fnc-slide__heading-line">
                <span>Just Thorspan>
              div>
            h2>
            <button type="button" class="fnc-slide__action-btn">
              Credits
              <span data-text="Credits">Creditsspan>
            button>
          div>
        div>
      div>
      
    div>
    <nav class="fnc-nav">
      <div class="fnc-nav__bgs">
        <div class="fnc-nav__bg m--navbg-green m--active-nav-bg">div>
        <div class="fnc-nav__bg m--navbg-dark">div>
        <div class="fnc-nav__bg m--navbg-red">div>
        <div class="fnc-nav__bg m--navbg-blue">div>
      div>
      <div class="fnc-nav__controls">
        <button class="fnc-nav__control">
          Black Widow
          <span class="fnc-nav__control-progress">span>
        button>
        <button class="fnc-nav__control">
          Captain America
          <span class="fnc-nav__control-progress">span>
        button>
        <button class="fnc-nav__control">
          Iron Man
          <span class="fnc-nav__control-progress">span>
        button>
        <button class="fnc-nav__control">
          Thor
          <span class="fnc-nav__control-progress">span>
        button>
      div>
    nav>
  div>
  
  <div class="demo-cont__credits">
    <div class="demo-cont__credits-close">div>
    <h2 class="demo-cont__credits-heading">Made byh2>
    <img src="//s3-us-west-2.amazonaws.com/s.cdpn.io/142996/profile/profile-512_5.jpg" alt="" class="demo-cont__credits-img" />
    <h3 class="demo-cont__credits-name">Nikolay Talanovh3>
    <a href="https://codepen.io/suez/" target="_blank" class="demo-cont__credits-link">My codepena>
    <a href="https://twitter.com/NikolayTalanov" target="_blank" class="demo-cont__credits-link">My twittera>
    <h2 class="demo-cont__credits-heading">Based onh2>
    <a href="https://dribbble.com/shots/2375246-Fashion-Butique-slider-animation" target="_blank" class="demo-cont__credits-link">Concept by Kreativa Studioa>
    <h4 class="demo-cont__credits-blend">Global Blend Modeh4>
    <div class="colorful-switch">
      <input type="checkbox" class="colorful-switch__checkbox js-activate-global-blending" id="colorful-switch-cb" />
      <label class="colorful-switch__label" for="colorful-switch-cb">
        <span class="colorful-switch__bg">span>
        <span class="colorful-switch__dot">span>
        <span class="colorful-switch__on">
          <span class="colorful-switch__on__inner">span>
        span>
        <span class="colorful-switch__off">span>
      label>
    div>
  div>
div>

CSS

部分 CSS 代码:

.fnc {
  /* you can add color names and their values here
  and then simply add classes like .m--blend-$colorName to .fnc-slide 
  to apply specific color for mask blend mode */
}
.fnc-slider {
  overflow: hidden;
  box-sizing: border-box;
  position: relative;
  height: 100vh;
}
.fnc-slider *, .fnc-slider *:before, .fnc-slider *:after {
  box-sizing: border-box;
}
.fnc-slider__slides {
  position: relative;
  height: 100%;
  transition: transform 1s 0.6666666667s;
}
.fnc-slider .m--blend-dark .fnc-slide__inner {
  background-color: #8a8a8a;
}
.fnc-slider .m--blend-dark .fnc-slide__mask-inner {
  background-color: #575757;
}
.fnc-slider .m--navbg-dark {
  background-color: #575757;
}
.fnc-slider .m--blend-green .fnc-slide__inner {
  background-color: #6d9b98;
}
.fnc-slider .m--blend-green .fnc-slide__mask-inner {
  background-color: #42605E;
}
.fnc-slider .m--navbg-green {
  background-color: #42605E;
}
.fnc-slider .m--blend-red .fnc-slide__inner {
  background-color: #ea2329;
}
.fnc-slider .m--blend-red .fnc-slide__mask-inner {
  background-color: #990e13;
}
.fnc-slider .m--navbg-red {
  background-color: #990e13;
}
.fnc-slider .m--blend-blue .fnc-slide__inner {
  background-color: #59aecb;
}
.fnc-slider .m--blend-blue .fnc-slide__mask-inner {
  background-color: #2D7791;
}
.fnc-slider .m--navbg-blue {
  background-color: #2D7791;
}
.fnc-slide {
  overflow: hidden;
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  transform: translate3d(0, 0, 0);
}

JS

部分JS代码:

fncSlider(".example-slider", {autoSlidingDelay: 4000});

var $demoCont = document.querySelector(".demo-cont");

[].slice.call(document.querySelectorAll(".fnc-slide__action-btn")).forEach(function($btn) {
  $btn.addEventListener("click", function() {
    $demoCont.classList.toggle("credits-active");
  });
});

document.querySelector(".demo-cont__credits-close").addEventListener("click", function() {
  $demoCont.classList.remove("credits-active");
});

document.querySelector(".js-activate-global-blending").addEventListener("click", function() {
  document.querySelector(".example-slider").classList.toggle("m--global-blending-active");
});

到此,仿 GitHub 登录页面的效果就实现啦!

完整源码下载⬇

到此我们的产品展示界面就完成了,本实验的完整代码已上传,下载地址:

http://43.142.11.221/125/

⭐️ 好书推荐

《人工智能导论》

在这里插入图片描述

【内容简介】

科大讯飞校企合编教材,涵盖人工智能各个重要体系,详解人工智能基础理论,详细解读算法逻辑:详解机器学习、人工神经网络、智能语音识别、自然语言处理、知识图谱与机器人等核心算法知识,清晰介绍实战步骤:有理论有实战,介绍了人工智能算法与技术的实际应用,步骤清楚,条理清晰,即学即用。

京东自营购买链接:《人工智能导论》

你可能感兴趣的:(100个前端优质项目,前端)