我注意到一些关于使用responsiveWidth和responsiveHeight为移动设备禁用fullpage.js的问题。不过,我希望实现相反的效果,因为我想在屏幕大小大于600px的情况下禁用fullpage.js。有办法解决这个问题吗?到目前为止,我已经在这里加入了一个jsfiddle。。我真的很感激你的建议。。谢谢您。: )

enter code here <div id="fullpage">

<div class="section">
</div>

<div class="section">
  <div id="carousel" class="snap">
    <div class="trail-card-snap">
      <div class="trails-card trails-bg-one">
        <div class="trails-card-content">
          <p>Card One</p>
        </div>
      </div>
    </div>

    <div class="trail-card-snap">
      <div class="trails-card trails-bg-two">
        <div class="trails-card-content">
          <p>Card Two</p>
        </div>
      </div>
    </div>

    <div class="trail-card-snap">
      <div class="trails-card trails-bg-three">
        <div class="trails-card-content">
          <p>Card Three</p>
        </div>
      </div>
    </div>

    <div class="trail-card-snap">
      <div class="trails-card trails-bg-four">
        <div class="trails-card-content">
          <p>Card Four</p>
        </div>
      </div>
    </div>

    <div class="trail-card-snap">
      <div class="trails-card trails-bg-five">
        <div class="trails-card-content">
          <p>Card Five</p>
        </div>
      </div>
    </div>

    <div class="trail-card-snap">
      <div class="trails-card trails-bg-six">
        <div class="trails-card-content">
          <p>Card Six</p>
        </div>
      </div>
    </div>

    <div class="trail-card-snap">
      <div class="trails-card trails-bg-seven">
        <div class="trails-card-content">
          <p>Card Seven</p>
        </div>
      </div>
    </div>

    <div class="trail-card-snap">
      <div class="trails-card trails-bg-eight">
        <div class="trails-card-content">
          <p>Card Eight</p>
        </div>
      </div>
    </div>
  </div>
</div>
</div>

html,body{
height: 100%;
width: 100%;
}

@media (max-width: 600px) {
#fullpage {
height: 100%;
}
.section {
height: 50%;
}
}

@media (min-width: 601px) {
#fullpage {
height: 100%;
}
.section {
height: 100%;
}

}


@media (max-width: 600px) {
/*Horizontal Scroll*/
#carousel {
/* Ensure that the contents flow horizontally */
overflow-x: auto;
white-space: nowrap;
display: flex;
-webkit-overflow-scrolling: touch;
width: 100%;
max-width: 370px;
margin: 0 auto;
margin-top: -50%;
}

#carousel::-webkit-scrollbar {
width: 0px;
background: transparent;
display: none;
}

#carousel.vertical {
flex-direction: column;
}

/* 2018 spec - For Safari 11, Chrome 69+ */
#carousel.snap {
scroll-snap-type: x mandatory;
-webkit-overflow-scrolling: touch;
/* Needed to work on iOS Safari */
margin-top: -50%;
}

#carousel.snap::-webkit-scrollbar {
width: 0px;
/* Remove scrollbar space */
background: transparent;
display: none;
}

#carousel.snap > .randomcard {
scroll-snap-align: center;
-webkit-overflow-scrolling: touch;
}

#carousel.snap::-webkit-scrollbar {
width: 0px;
/* Remove scrollbar space */
background: transparent;
display: none;
}

#carousel.snap.vertical {
flex-direction: column;
scroll-snap-type: y mandatory;
}

/* 2015 spec - For Firefox, Edge, IE */
#carousel.snap {
scroll-snap-type: mandatory;
-ms-scroll-snap-type: mandatory;
scroll-snap-points-x: repeat(100%);
-ms-scroll-snap-points-x: repeat(100%);
-webkit-overflow-scrolling: touch;
margin-top: -50%;
}

#carousel .snap.kids-cards {
scroll-snap-type: mandatory;
-ms-scroll-snap-type: mandatory;
scroll-snap-points-x: repeat(100%);
-ms-scroll-snap-points-x: repeat(100%);
-webkit-overflow-scrolling: touch;
}

#carousel.snap.vertical {
scroll-snap-points-x: initial;
-ms-scroll-snap-points-x: initial;
scroll-snap-points-y: repeat(100%);
-ms-scroll-snap-points-y: repeat(100%);
}
}

@media (max-width: 600px) {
#carousel > .trail-card-snap {
height: 100%;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
-webkit-overflow-scrolling: touch;
}

#carousel > .trail-card-snap::-webkit-scrollbar {
width: 0px;
background: transparent;
display: none;
}

#carousel.snap > .trail-card-snap {
scroll-snap-align: center;
-webkit-overflow-scrolling: touch;
}
}

@media (max-width: 600px) {
.trails-card-content p {
color: rgb(190, 0, 207);
text-align: left;
font-size: 16px;
font-size: 2em;
font-weight: 700;
}

.trails-card {
border-radius: 0.8rem;
box-shadow: 0 20px 40px -14px rgba(0, 0, 0, 0.25);
display: flex;
flex-direction: column;
overflow: hidden;
margin-top: 10%;
margin-left: 10px;
margin-right: 10px;
height: 500px;
width: 380px;
}

.trails-bg-one {
background: url("img/TrailTile-1.png");
background-repeat: no-repeat;
background-size: cover;
}

.trails-bg-two {
background: url("img/TrailTile-3.png");
background-repeat: no-repeat;
background-size: cover;
}

.trails-bg-three {
background: url("img/TrailTile-4.png");
background-repeat: no-repeat;
background-size: cover;
}

.trails-bg-four {
background: url("img/TrailTile-3.png");
background-repeat: no-repeat;
background-size: cover;
}

.trails-bg-five {
background: url("img/TrailTile-1.png");
background-repeat: no-repeat;
background-size: cover;
}

.trails-bg-six {
 background: url("img/TrailTile-1.png");
background-repeat: no-repeat;
background-size: cover;
}

.trails-bg-seven {
background: url("img/TrailTile-1.png");
background-repeat: no-repeat;
background-size: cover;
}

.trails-bg-eight {
background: url("img/TrailTile-1.png");
background-repeat: no-repeat;
background-size: cover;
}

#trails-event-image {
margin: 0 auto;
width: 100%;
height: auto;
max-width: 330px;
padding-top: 20px;
padding-bottom: 20px;
box-shadow: 0 0px 0px rgba(0, 0, 0, 0.19), 0 0px
0px rgba(0, 0, 0, 0.23);
}
}

/*Desktop / Tablet*/

@media (min-width: 601px) {
#carousel {
display: grid;
max-width: 100%;
margin: 0 auto;
grid-gap: 1rem;
 grid-template-columns: repeat(auto-fit,
 minmax(300px, 1fr));
grid-auto-rows: minmax(150px, auto);
margin-top: -30%;


}
.trails-card {
max-width: 100%;
border-radius: 5px;
box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
transition: all 0.3s;
}
.trails-card:hover {
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.8);
}
.trails-card img {
width: 100%;
object-fit: cover;
}

.trails-card {
border-radius: 0.25rem;
box-shadow: 0 20px 40px -14px rgba(0, 0, 0, 0.25);
display: inline-block;
overflow: hidden;
width: 100%;
max-width: 350px;
}

.trails-bg-one {
background: url("img/TrailTile-1.png");
background-repeat: no-repeat;
width: 100%;
max-width: 350px;
height: 350px;
}

.trails-bg-two {
background: url("img/TrailTile-3.png");
background-repeat: no-repeat;
width: 100%;
max-width: 350px;
height: 350px;
}

.trails-bg-three {
background: url("img/TrailTile-4.png");
background-repeat: no-repeat;
width: 100%;
max-width: 350px;
height: 350px;
}

.trails-bg-four {
background: url("img/TrailTile-3.png");
background-repeat: no-repeat;
width: 100%;
max-width: 350px;
height: 350px;
}

.trails-bg-five {
background: url("img/TrailTile-1.png");
background-repeat: no-repeat;
width: 100%;
max-width: 350px;
height: 350px;
}

.trails-bg-six {
background: url("img/TrailTile-1.png");
background-repeat: no-repeat;
width: 100%;
max-width: 350px;
height: 350px;
}

.trails-bg-seven {
background: url("img/TrailTile-1.png");
background-repeat: no-repeat;
width: 100%;
max-width: 350px;
height: 350px;
}

.trails-bg-eight {
background: url("img/TrailTile-1.png");
background-repeat: no-repeat;
width: 100%;
max-width: 350px;
height: 350px;
}

.trails-card-content {
  padding: 1rem;
}

.trails-card-content p {
  color: rgb(190, 0, 207);
text-align: left;
font-size: 16px;
font-size: 2em;
font-weight: 700;
 }
 }



enter code here<script>
$(document).ready(function () {
  $('#fullpage').fullpage({
    //options here
  });

  //methods
});
</script>


 <script>
 function toggleSnap() {
   var snapEnabled =         document.getElementById('carousel').classList.toggle('sn.ap');
  //document.getElementById('otherSnappingState').innerText = //snapEnabled ? 'off' : 'on';
}

最佳答案

您可以用下面的链接替换您的全页脚本链接-这意味着全页将只加载小于600px的大小。

<script>
if (screen && screen.width < 600) {
document.write('<script type="text/javascript" src="http://your-file-path/fullpage.js"><\/script>');
}
</script>

您可以根据您的要求将数字(600)更改为768或991并设置条件….哦,不要忘记将文件路径更改为您自己的代码

10-01 00:58