js+css实现炫酷拖拽式图文菜单效果代码

代码语言:html

所属分类:菜单导航

代码描述:js+css实现炫酷拖拽式图文菜单效果代码

代码标签: js css 炫酷 拖拽式 图文 菜单

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
<style>


:root {
  --font1: 1.5rem;

  --family1: "Gotham-Black";

  --color1: rgba(0, 0, 0, 1);
  --color2: rgba(29, 30, 34, 1);
  --color3: rgba(173, 175, 188, 1);
  --color4: rgba(255, 255, 255, 1);
  
  --slideScaleX: 0.8;
  --slideScaleY: 0.4;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-font-kerning: auto;
          font-kerning: auto;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: var(--color2);
}

a {
  text-decoration: none;
}

img {
  width: 100%;
  height: 100%;
  -o-object-fit: cover;
     object-fit: cover;
  display: block;
}

.navbar-main {
  width: 100vw;
  height: 100vh;
  font-size: var(--font1);
  font-weight: 700;
  font-family: Roboto, sans-serif;
  text-transform: uppercase;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
  font-family: var(--family1);
  white-space: nowrap;
  position: fixed;
  top: 0;
  left: 0;
}

.navbar-main .navbar__list {
  top: calc(50% + var(--font1) / 2);
  width: 100%;
  height: 100%;
  position: absolute;
  text-align: center;
  pointer-events: none;
}

.navbar-main a {
  color: var(--color2);
  -webkit-text-stroke: 1px var(--color3);
  opacity: 0.5;
  transition: opacity 0.5s linear;
  pointer-events: auto;
  
  -webkit-user-drag: none 
}

.show-meta > a {
  -webkit-text-stroke: 0 transparent;
  opacity: 1;
  color: var(--color4);
}

.slide-images {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
}

.slide__list {
  position: relative;
  background-color: black;
  width: 100%;
  height: 100%;
  margin-left: 15px;
  margin-right: 15px;
  margin-left: auto;
  margin-right: auto;
  transition: transform 0.5s;
  overflow: hidden;
}

.slide__list:after{
  position: absolute;
  content: "";
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.4);
}

/** resize slide **/
.mouse-down .slide__list{
  transform: scale(var(--slideScaleX), var(--slideScaleY));
}

.mouse-down .image__item{
  transform: scale(calc(1 / var(--slideScaleX)), calc(1 / var(--slideScaleY)));
}

.image__item {
  position: absolute;
  height: 100%;
  width: 100%;
  display: none;
  transition: transform 0.5s;
}

.active.image__item {
  display: block;
}

.cursor {
  width: 50px;
  height: 50px;
  z-index: 100;
  pointer-events: none;
  position: absolute;
  transform: scale(0.2);
  top: 0;
  left: 0;
  mix-blend-mode: difference;
  border-radius: 50%;
  background: var(--color4);
  transform-origin: 0 0;
}

.slide {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 30vh;
  transition: transform 0.7s, opacity 0.7s;
  transform: translatey(calc(-50% - var(--font1) / 2));
}

.prev,
.next {
  opacity: 0;
  pointer-events: none;
}

.next {
  transform: translatey(-15%);
  opacity: 0;
}

.prev {
  transform: translatey(-80%);
}

.scrolling .next,
.scrolling .prev {
  opacity: 1;
  pointer-events: auto;
}

.scrolling .slide {
  transform: translatey(calc(-50% - var(--font1) / 2));
}

@media screen and (min-width: 576px) {
  :root {
    --font1: 2rem;
  }
}

@media screen and (min-width: 768px) {
  :root {
    --font1: 3rem;
  }
}
</style>

</head>

<body>

    <nav class="navbar-main .navbar-slider">
        <div class="slide-images">
            <div class="slide__list">
                <div class="active image__item"><img src="//repo.bfw.wiki/bfwrepo/image/638569902ece3.png" alt=""></div>
                <div class="image__item"><img src="//repo.bfw.wiki/bfwrepo/image/638569cf01af9.png" alt=""></div>
                <div class="image__item"><img src="//repo.bfw.wiki/bfwrepo/image/638569b7eac95.png" alt=""></div>
                <div class="image__item"><img src="//repo.bfw.wiki/bfwrepo/image/638569ee7cd96.png" alt=""></div>
                <div class="image__item"><img src="//repo.bfw.wiki/bfwrepo/image/63856a3497ea4.png" alt=""></div>
                <div class="image__item"><img src="//repo.bfw.wiki/bfwrepo/image/63856a5b46c8a.png" alt=""></div>
            </div>
        </div>
        <div class="navbar__list">
            <div class="slide show-meta"><a href="#" class="nav__link">Black Gentleman</a></div>
            <div class="slide next"><a href="#" class="nav__link">The Black Beginner</a></div>
            <div class="slide next"><a href="#" class="nav__link">The Blood Spear</a></div>
            <div class="slide next"><a href="#" class="nav__link">Old Angel</a></div>
            <div class="slide next"><a href="#" class="nav__link">The Dark Veil</.........完整代码请登录后点击上方下载按钮下载查看

网友评论0