我的JavaScript滑块不起作用

时间:2017-02-15 06:50:25

标签: jquery html css

我尝试添加一个滑块,但它无效。

滑块:https://codepen.io/amitasaurus/pen/OMbmPO

网站索引:https://codepen.io/GARDFIELD3/pen/oBVzLP

结合它们,我得到:https://codepen.io/GARDFIELD3/pen/jyJMVr

(function($) {

  $.fn.menumaker = function(options) {

    var cssmenu = $(this),
      settings = $.extend({
        title: "Menu",
        format: "dropdown",
        breakpoint: 768,
        sticky: false
      }, options);

    return this.each(function() {
      cssmenu.find('li ul').parent().addClass('has-sub');
      if (settings.format != 'select') {
        cssmenu.prepend('<div id="menu-button">' + settings.title + '</div>');
        $(this).find("#menu-button").on('click', function() {
          $(this).toggleClass('menu-opened');
          var mainmenu = $(this).next('ul');
          if (mainmenu.hasClass('open')) {
            mainmenu.hide().removeClass('open');
          } else {
            mainmenu.show().addClass('open');
            if (settings.format === "dropdown") {
              mainmenu.find('ul').show();
            }
          }
        });
        $('.flexslider').flexslider({
          animation: "slide",
          controlNav: false
        });

        multiTg = function() {
          cssmenu.find(".has-sub").prepend('<span class="submenu-button"></span>');
          cssmenu.find('.submenu-button').on('click', function() {
            $(this).toggleClass('submenu-opened');
            if ($(this).siblings('ul').hasClass('open')) {
              $(this).siblings('ul').removeClass('open').hide();
            } else {
              $(this).siblings('ul').addClass('open').show();
            }
          });
        };

        if (settings.format === 'multitoggle') multiTg();
        else cssmenu.addClass('dropdown');
      } else if (settings.format === 'select') {
        cssmenu.append('<select style="width: 100%"/>').addClass('select-list');
        var selectList = cssmenu.find('select');
        selectList.append('<option>' + settings.title + '</option>', {
          "selected": "selected",
          "value": ""
        });
        cssmenu.find('a').each(function() {
          var element = $(this),
            indentation = "";
          for (i = 1; i < element.parents('ul').length; i++) {
            indentation += '-';
          }
          selectList.append('<option value="' + $(this).attr('href') + '">' + indentation + element.text() + '</option');
        });
        selectList.on('change', function() {
          window.location = $(this).find("option:selected").val();
        });
      }

      if (settings.sticky === true) cssmenu.css('position', 'fixed');

      resizeFix = function() {
        if ($(window).width() > settings.breakpoint) {
          cssmenu.find('ul').show();
          cssmenu.removeClass('small-screen');
          if (settings.format === 'select') {
            cssmenu.find('select').hide();
          } else {
            cssmenu.find("#menu-button").removeClass("menu-opened");
          }
        }

        if ($(window).width() <= settings.breakpoint && !cssmenu.hasClass("small-screen")) {
          cssmenu.find('ul').hide().removeClass('open');
          cssmenu.addClass('small-screen');
          if (settings.format === 'select') {
            cssmenu.find('select').show();
          }
        }
      };
      resizeFix();
      return $(window).on('resize', resizeFix);




    });
  };
})(jQuery);

(function($) {
  $(document).ready(function() {

    $(document).ready(function() {
      $("#cssmenu").menumaker({
        title: "Menu",
        format: "dropdown"
      });

      $("#cssmenu a").each(function() {
        var linkTitle = $(this).text();
        $(this).attr('data-title', linkTitle);
      });
    });

  });
})(jQuery);
* {
  margin: 0;
  padding: 0;
  outline: 0;
}
body {
  font-size: 12px;
  line-height: 18px;
  font-family: arial, sans-serif;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  background: linear-gradient(45deg, rgba(0, 150, 0, 0.5), rgba(205, 0, 255, 0.5)), url(http://i.imgur.com/ZR1Dkyk.jpg);
  background-size: cover;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
#header_holder {
  width: 100%;
  position: fixed;
  top: 0px;
  left: 0;
  background: #222;
  z-index: 100;
}
#header {
  width: 100%;
  margin: auto;
  height: 46px;
  position: relative;
}
#max3semneblue {
  float: left;
  width: 100%;
  height: 46px;
  border-bottom: 4px solid #cc1e1e;
}
#noscrollright::-webkit-scrollbar {
  width: 5px;
}
::-webkit-scrollbar-track {
  background-color: #000;
}
::-webkit-scrollbar-thumb {
  background: #fff;
}
#content {
  width: 400px;
  /*change is here */
  margin: 0 auto;
  float: right;
  padding: 1.4px 0 30px;
  padding-right: 55px;
}
.icon {
  margin: 0 14px;
  width: 40px;
  border-radius: 3px;
  -webkit-transform: rotate(0deg);
  -webkit-transition: -webkit-transform 0.25s ease-in-out;
}
.icon:hover {
  -webkit-transform: rotate(350deg);
  -webkit-transition: -webkit-transform 0.25s ease-in-out;
}
@import url(http://fonts.googleapis.com/css?family=Raleway);
 #cssmenu,
#cssmenu ul,
#cssmenu ul li,
#cssmenu ul li a,
#cssmenu #menu-button {
  margin: 0;
  padding: 0;
  border: 0;
  list-style: none;
  line-height: 1;
  display: block;
  position: relative;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}
#cssmenu:after,
#cssmenu > ul:after {
  display: block;
  clear: both;
  visibility: hidden;
  line-height: 0;
  height: 0;
}
#cssmenu #menu-button {
  display: none;
}
#cssmenu {
  width: auto;
  font-family: Raleway, sans-serif;
  line-height: 1;
}
#cssmenu > ul {
  width: 555PX;
  BACKGROUND-COLOR: RED;
}
#cssmenu > ul > li {
  float: left;
  -webkit-perspective: 1000px;
  -moz-perspective: 1000px;
  perspective: 1000px;
}
#cssmenu.align-center > ul {
  font-size: 0;
  text-align: center;
}
#cssmenu.align-center > ul > li {
  display: inline-block;
  float: none;
}
#cssmenu.align-right > ul > li {
  float: right;
}
#cssmenu > ul > li > a {
  padding: 16px 20px;
  font-size: 14px;
  color: #ffffff;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-decoration: none;
  background: #c61515;
  -webkit-transition: all .3s;
  -moz-transition: all .3s;
  -o-transition: all .3s;
  transition: all .3s;
  -webkit-transform-origin: 50% 0;
  -moz-transform-origin: 50% 0;
  transform-origin: 50% 0;
  -webkit-transform-style: preserve-3d;
  -moz-transform-style: preserve-3d;
  transform-style: preserve-3d;
}
#cssmenu > ul > li.active > a {
  font-weight: bold;
  color: #000000;
}
#cssmenu > ul > li:hover > a,
#cssmenu > ul > li > a:hover {
  color: #dff2fa;
  -webkit-transform: rotateX(90deg) translateY(-23px);
  -moz-transform: rotateX(90deg) translateY(-23px);
  transform: rotateX(90deg) translateY(-23px);
  -ms-transform: none;
}
#cssmenu > ul > li > a::before {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: -1;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  padding: 16px 20px;
  color: #dff2fa;
  background: #19799f;
  content: attr(data-title);
  -webkit-transition: background 0.3s;
  -moz-transition: background 0.3s;
  transition: background 0.3s;
  -webkit-transform: rotateX(-90deg);
  -moz-transform: rotateX(-90deg);
  transform: rotateX(-90deg);
  -webkit-transform-origin: 50% 0;
  -moz-transform-origin: 50% 0;
  transform-origin: 50% 0;
  -ms-transform: translateY(- -18px);
}
#cssmenu > ul > li:hover > a::before,
#cssmenu > ul > li > a:hover::before {
  background: #3db2e1;
}
#cssmenu.small-screen {
  width: 100%;
}
#cssmenu.small-screen > ul,
#cssmenu.small-screen.align-center > ul {
  width: 100%;
  text-align: left;
}
#cssmenu.small-screen > ul > li,
#cssmenu.small-screen.align-center {
  float: none;
  display: block;
  border-top: 1px solid rgba(100, 100, 100, 0.1);
}
#cssmenu.small-screen > ul > li:hover > a,
#cssmenu.small-screen > ul > li > a:hover {
  color: #dff2fa;
  -webkit-transform: none;
  -moz-transform: none;
  transform: none;
  -ms-transform: none;
}
#cssmenu.small-screen > ul > li > a::before {
  display: none;
}
#cssmenu.small-screen #menu-button {
  display: block;
  padding: 16px 20px;
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
  color: #ffffff;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: #3db2e1;
}
#cssmenu.small-screen #menu-button:after {
  content: "";
  position: absolute;
  right: 20px;
  top: 17px;
  display: block;
  -webkit-box-sizing: content-box;
  -moz-box-sizing: content-box;
  box-sizing: content-box;
  border-top: 2px solid #ffffff;
  border-bottom: 2px solid #ffffff;
  width: 22px;
  height: 3px;
}
#cssmenu.small-screen #menu-button.menu-opened:after {
  border-top: 2px solid #dff2fa;
  border-bottom: 2px solid #dff2fa;
}
#cssmenu.small-screen #menu-button:before {
  content: "";
  position: absolute;
  right: 20px;
  top: 27px;
  display: block;
  width: 22px;
  height: 2px;
  background: #ffffff;
}
#cssmenu.small-screen #menu-button.menu-opened:before {
  background: #dff2fa;
}
@import url(https://fonts.googleapis.com/css?family=Syncopate:700);
 body {
  text-align: center;
}
svg {
  position: absolute;
  left: 500px;
  top: 42px;
  margin-top: 1vh;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 1.2s ease-in-out;
}
svg:hover .dev {
  opacity: 1;
  transition: opacity 0.3s ease-in;
}
svg:hover .line1 {
  transform: translateY(0px);
  -webkit-transform: translateY(0px);
  -moz-transform: translateY(0px);
}
.dev {
  opacity: 0;
  transition: opacity 0.3s ease-out;
  -webkit-transition: opacity 0.3s ease-out;
  -moz-transition: opacity 0.3s ease-out;
}
line {
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: dash 5s linear forwards;
  -webkit-animation: dash 5s linear forwards;
  -moz-animation: dash 5s linear forwards;
}
.line1 {
  transform: translateY(30px);
  -webkit-transform: translateY(30px);
  -moz-transform: translateY(30px);
  transition: all 0.5s ease-in-out;
  -webkit-transition: all 0.5s ease-in-out;
  -moz-transition: all 0.5s ease-in-out;
}
@keyframes dash {
  to {
    stroke-dashoffset: 0;
  }
}
@-moz-keyframes dash {
  to {
    stroke-dashoffset: 0;
  }
}
@-webkit-keyframes dash {
  to {
    stroke-dashoffset: 0;
  }
}
.flexslider {
  width: 790px;
  margin: 0 auto;
  box-shadow: none;
}
.flexslider li {
  position: relative;
}
.flexslider li .meta {
  position: absolute;
  bottom: 20px;
  left: 20px;
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  font-family: 'Roboto', sans-serif;
}
.flexslider li h1 {
  background: rgba(51, 51, 51, 0.5);
  padding: 12px 18px 12px;
  margin-bottom: 0;
  font-size: 1.8em;
  font-weight: 300;
}
.flexslider li h2 {
  background: rgba(51, 51, 51, 0.5);
  padding: 13px 18px 11px;
  font-size: 1.1em;
  margin-bottom: 0;
  font-weight: 300;
}
.flexslider li .category {
  display: flex;
  flex-direction: row;
}
.flexslider li .category p {
  background: #e43837;
  margin-right: 7px;
  font-size: 1.1em;
  padding: 12px 18px 10px;
  font-weight: 300;
}
.flexslider li .category span {
  background: #e43837;
  margin-top: 17px;
  padding: 8px 12px 0;
  font-size: 0.9em;
  font-weight: 300;
  height: 26px;
}
.flexslider li h1,
.flexslider li h2,
.flexslider li .category p,
.flexslider li .category span {
  -webkit-animation-duration: .6s;
  animation-duration: .6s;
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both;
  -webkit-animation-name: fadeOutLeft;
  animation-name: fadeOutLeft;
}
.flexslider li.flex-active-slide .meta h1,
.flexslider li.flex-active-slide .meta h2,
.flexslider li.flex-active-slide .meta .category p,
.flexslider li.flex-active-slide .meta .category span {
  -webkit-animation-delay: .4s;
  animation-delay: .4s;
  -webkit-animation-duration: .6s;
  animation-duration: .6s;
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both;
  -webkit-animation-name: fadeInLeft;
  animation-name: fadeInLeft;
}
.flexslider li.flex-active-slide .meta h2 {
  -webkit-animation-delay: .5s;
  animation-delay: .5s;
}
.flexslider li.flex-active-slide .meta .category p {
  -webkit-animation-delay: .6s;
  animation-delay: .6s;
}
.flexslider li.flex-active-slide .meta .category span {
  -webkit-animation-delay: .8s;
  animation-delay: .8s;
}
.flex-direction-nav {
  position: absolute;
  top: 0;
  left: 30px;
}
.flex-direction-nav a {
  text-decoration: none;
  display: block;
  width: 30px;
  height: 30px;
  background-color: #333;
  margin: -20px 0 0;
  position: absolute;
  top: 50px;
  z-index: 10;
  overflow: hidden;
  opacity: .5;
  cursor: pointer;
  color: #fff;
  -webkit-transition: all .3s ease;
  -moz-transition: all .3s ease;
  transition: all .3s ease;
}
.flex-direction-nav .flex-prev {
  text-align: left;
  left: -10px;
}
.flex-direction-nav .flex-next {
  text-align: right;
  left: 30px;
}
.flexslider:hover .flex-prev {
  left: -10px;
}
.flexslider:hover .flex-next {
  left: 30px;
}
.flexslider:hover .flex-next:hover,
.flexslider:hover .flex-prev:hover {
  opacity: 1;
}
.flex-direction-nav a:before {
  font-family: FontAwesome;
  content: '\f104';
  font-size: 25px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  top: 1px;
  padding: 2px;
}
.flex-direction-nav a.flex-next:before {
  content: '\f105';
}
@-webkit-keyframes fadeInLeft {
  0% {
    opacity: 0;
    -webkit-transform: translate3d(-100%, 0, 0);
    transform: translate3d(-100%, 0, 0);
  }
  100% {
    opacity: 1;
    -webkit-transform: none;
    transform: none;
  }
}
@keyframes fadeInLeft {
  0% {
    opacity: 0;
    -webkit-transform: translate3d(-100%, 0, 0);
    transform: translate3d(-100%, 0, 0);
  }
  100% {
    opacity: 1;
    -webkit-transform: none;
    transform: none;
  }
}
@-webkit-keyframes fadeOutLeft {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    -webkit-transform: translate3d(-100%, 0, 0);
    transform: translate3d(-100%, 0, 0);
  }
}
@keyframes fadeOutLeft {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    -webkit-transform: translate3d(-100%, 0, 0);
    transform: translate3d(-100%, 0, 0);
  }
}
<html lang="en-US" xmlns="http://www.w3.org/1999/xhtml" dir="ltr">

<head>
  <title>Max3Semne #home</title>
  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
  <meta charset='utf-8'>
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="shortcut icon" href="favicon.ico" />
  <link rel="stylesheet" href="style.css" type="text/css" media="all" />
  <!--[if IE 6]>
		<link rel="stylesheet" href="css/ie6.css" type="text/css" media="all" />		
	<![endif]-->
  <link href='https://fonts.googleapis.com/css?family=Play:400,700&amp;subset=latin,cyrillic-ext,greek,greek-ext,latin-ext,cyrillic' rel='stylesheet' type='text/css' />
  <script src="https://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
  <script src="script.js"></script>
  <link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Syncopate:700">
  <link rel="stylesheet" type="text/css" href="https://fonts.google.com/?selection.family=Josefin+Sans">




</head>

<body>
  <div id='header_holder'>
    <div id='header'>
      <div id='max3semneblue'></div>
      <div id='pink'></div>
      <div id='green'></div>
      <div id='orange'></div>
      <div id='blue2'></div>
      <div id='purple2'>
        <h4 style="position: absolute;  left: 77%; top: 0%"><div id="content">
  <div id="content">
          <a href="https://www.facebook.com/Max3Semne/"> 
   <img src="http://wp-time.com/wp-content/uploads/2016/03/facebook.png" class="icon" /></a>
        <a href="http://steamcommunity.com/groups/max3semne?l=romanian">
   <img src="https://web2schools.juliarizza.com/web2schools/static/images/message-icon.png" class="icon" /></a>
          <a href="http://www.max3semne.ro/forum/index.php?app=members&module=messaging">
   <img src="https://upload.wikimedia.org/wikipedia/commons/d/d3/User_Circle.png" class="icon" /></a>
        <a href="http://steamcommunity.com/groups/max3semne?l=romanian">
   <img src="http://images.akamai.steamusercontent.com/ugc/35241878917010420/2DDCE514E0EDF58F6C0071C21EB641F16B4508CC/" class="icon" /></a> </h4>
        <h3 style="position: absolute;  left: 0%; top: 0%">
  <div id="content">
   	       <div id='cssmenu'>
           <ul>
             <li class='active'><a href='#'>Home</a></li>
             <li><a href='#'>FORUM</a></li>
             <li><a href='#'>SERVERE</a></li>
             <li><a href='#'>ASISTENTA</a></li>
           </ul>
       </div> </h3>

        <p style="font-family:Syncopate;">
          <svg height="200" width="300" viewBox="0 0 300 200">
            <text>
              <tspan x="0" dy="34px" y="0" font-size="12" fill="#ffffff" class="dev">
                oPenED by costY&Gardfield
                <3 </tspan>
                  <tspan x="0" dy="80px" y="34" font-size="33" fill="#E74C3C">
                    MAX3SEMNE
                  </tspan>
                  <tspan x="0" dy="35px" y="112" font-size="13" fill="#ffffff">
                    community gaming romania
                  </tspan>
            </text>
            <line x1="0" y1="2" x2="282" y2="2" style="stroke:#3498DB; stroke-width:3;" class="line1" />
            <line transform="translate(282, 0) scale(-1, 1)" x1="0" y1="85%" x2="282" y2="85%" style="stroke:#3498DB; stroke-width:3;" class="line2" />
          </svg>
          <div class="flexslider left">
            <ul class="slides">
              <li>
                <img src="http://lorempicsum.com/up/790/460/4">
                <div class="meta">
                  <h1>Lorem ipsum dolor sit amet, consectetur.</h1>
                  <h2>Lorem ipsum dolor sit.</h2>
                  <div class="category">
                    <p>$286600</p>
                    <span>Category</span>
                  </div>
                </div>
              </li>
              <li>
                <img src="http://lorempicsum.com/up/790/460/2">
                <div class="meta">
                  <h1>Lorem ipsum dolor sit amet, consectetur.</h1>
                  <h2>Lorem ipsum dolor sit.</h2>
                  <div class="category">
                    <p>$415000</p>
                    <span>Category</span>
                  </div>
                </div>
              </li>
              <li>
                <img src="http://lorempicsum.com/up/790/460/3">
                <div class="meta">
                  <h1>Lorem ipsum dolor sit amet, consectetur.</h1>
                  <h2>Lorem ipsum dolor sit.</h2>
                  <div class="category">
                    <p>$415000</p>
                    <span>Category</span>
                  </div>
                </div>
              </li>
              <li>
                <img src="http://lorempicsum.com/up/790/460/5">
                <div class="meta">
                  <h1>Lorem ipsum dolor sit amet, consectetur.</h1>
                  <h2>Lorem ipsum dolor sit.</h2>
                  <div class="category">
                    <p>$415000</p>
                    <span>Category</span>
                  </div>
                </div>
              </li>
            </ul>
          </div>
      </div>
    </div>
  </div>
</body>

</html>

问题:

1 个答案:

答案 0 :(得分:0)

在任何脚本之外的页面就绪时启动脚本

$(function(){ 
  $('.flexslider').flexslider({
          animation: "slide",
          controlNav: false
        });
});

按如下方式修改你的css:

.flexslider {
 clear:both;
  position:relative;
}

演示:http://codepen.io/anon/pen/RKdGZm

您需要在页面头部分添加以下脚本+ css:

<link href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.css'>
<link href='https://cdnjs.cloudflare.com/ajax/libs/flexslider/2.2.0/flexslider-min.css'>
<script src="https://cdnjs.cloudflare.com/ajax/libs/flexslider/2.2.0/jquery.flexslider-min.js"></script>