加载无限滚动页面时,加载页面的 CSS 发生变化

发布于 2024-12-27 09:26:22 字数 3400 浏览 2 评论 0原文

我在我正在构建的网站上有无限滚动、同位素和名为 .mb_miniplayer_play 的音频播放器。我遇到的问题是,当加载新页面时,先前加载的页面上的 css 会发生变化。假设页面 2 已加载,页面 1 的 css 发生了变化。但它只是一种元素。

我尝试了各种方法,但似乎没有什么可以使所有页面看起来和正常工作。

代码如下:

  **//Audio jquery**

  $(function AudioEvents(){

    $(".audio").mb_miniPlayer({
    width:210,
    height:34,
    inLine:false,
    onEnd:playNext
    });

    var $audios = $('.audio');

    function playNext(idx) {
    var actualPlayer=$audios.eq(idx),
    $filteredAtoms = $container.data('isotope').$filteredAtoms,
    isotopeItemParent = actualPlayer.parents('.isotope-item'),
    isoIndex = $filteredAtoms.index( isotopeItemParent[0] ),
    nextIndex = ( isoIndex + 1 ) % $filteredAtoms.length;

    $filteredAtoms.eq( nextIndex ).find('.audio').mb_miniPlayer_play();
    }



  **//Inifinite Scroll**

  var $container = $('#container');

  $container.isotope({
    itemSelector : '.square'
  });

  $container.infinitescroll({
    navSelector  : '#page_nav',    // selector for the paged navigation 
    nextSelector : '#page_nav a',  // selector for the NEXT link (to page 2)
    itemSelector : '.square',     // selector for all items you'll retrieve
    loading: {
        finishedMsg: 'No more pages to load.',
        img: 'http://i.imgur.com/qkKy8.gif'
      }
    },

    // call Isotope as a callback
      function( newElements ) {
      var $newElements = $(newElements);

      AudioEvents( $newElements );

      // add hover events for new items
      bindSquareEvents( $newElements );

      setTimeout(function() {
      $container.isotope('insert', $newElements );
      }, 1000);
      });
  });

有没有人经历过这个。我认为我的 jquery 代码不正确或缺少某些内容,但我不知道是什么。

这是 HTML 标记...正在更改的 div 是 .download。加载页面上“顶部”的 css 设置需要使其看起来正确,即 top:-114,而新加载的页面只需要 top:-24 即可看起来正确。

<div class="square techno">

<!-- DJ Picture -->
<img src="Pictures/dirtyharris.jpg" class="img1" />
        <div class="boxtop">
        <span class="genre">Techno</span>
        </div>

        <div class="box">
        <a class="close" href="#close">&times;</a>
        <!-- DJ Name -->
        <h1> ThreeSixty & Dirty Harris</h1>

        <!-- Song Title -->
        <h2>Louka (Funkagenda Re-Edit)</h2>

         <!--Song Description(179 characters with spaces)-->
        <h4>I had to include this one since it literally took over control of me while driving the other morning. I was bouncing around in my seat like a little kid who desparately needs to use the bathroom. </h4> 

            <div class="buttons">
            <!--Song file info-->
            <div class="player">
            <a id="m85" class="audio {skin:'#010101',showVolumeLevel:false,showTime:false,showRew:false,ogg:'MP3/Adrian Lux feat. The Good Natured - Alive (Extended Mix).ogg'}" href="MP3/Adrian Lux feat. The Good Natured - Alive (Extended Mix).mp3"></a></div>


                <!--Download Link-->
                <div class="download">
                <a href="MP3/ThreeSixty, Funkagenda - Loudka (Funkagenda Re-Edit).mp3" title='Right Click and Save Link As'>
                <img src="img/dlicon.png"/></a>

                </div>
            </div>
        </div>

</div>

I have Infinite Scroll, Isotope, and an audio player by the name of .mb_miniplayer_play on this site I am building. The problem I am having is when a new page is loaded in, the css on previously loaded pages change. Lets say page 2 is loaded in, the css of page 1 changes. but it is only of one element.

I have tried various things, but nothing seems to make all of the pages look and work properly.

The code is as follows:

  **//Audio jquery**

  $(function AudioEvents(){

    $(".audio").mb_miniPlayer({
    width:210,
    height:34,
    inLine:false,
    onEnd:playNext
    });

    var $audios = $('.audio');

    function playNext(idx) {
    var actualPlayer=$audios.eq(idx),
    $filteredAtoms = $container.data('isotope').$filteredAtoms,
    isotopeItemParent = actualPlayer.parents('.isotope-item'),
    isoIndex = $filteredAtoms.index( isotopeItemParent[0] ),
    nextIndex = ( isoIndex + 1 ) % $filteredAtoms.length;

    $filteredAtoms.eq( nextIndex ).find('.audio').mb_miniPlayer_play();
    }



  **//Inifinite Scroll**

  var $container = $('#container');

  $container.isotope({
    itemSelector : '.square'
  });

  $container.infinitescroll({
    navSelector  : '#page_nav',    // selector for the paged navigation 
    nextSelector : '#page_nav a',  // selector for the NEXT link (to page 2)
    itemSelector : '.square',     // selector for all items you'll retrieve
    loading: {
        finishedMsg: 'No more pages to load.',
        img: 'http://i.imgur.com/qkKy8.gif'
      }
    },

    // call Isotope as a callback
      function( newElements ) {
      var $newElements = $(newElements);

      AudioEvents( $newElements );

      // add hover events for new items
      bindSquareEvents( $newElements );

      setTimeout(function() {
      $container.isotope('insert', $newElements );
      }, 1000);
      });
  });

Has anyone experienced this. I presume my jquery code is incorrect or missing something, but I don't know what.

Here is the HTML markup... The div that is changing is .download. The css settings for 'Top' on the loaded pages need to make it look proper is top:-114 while the newly loaded pages only need top:-24 to look proper.

<div class="square techno">

<!-- DJ Picture -->
<img src="Pictures/dirtyharris.jpg" class="img1" />
        <div class="boxtop">
        <span class="genre">Techno</span>
        </div>

        <div class="box">
        <a class="close" href="#close">×</a>
        <!-- DJ Name -->
        <h1> ThreeSixty & Dirty Harris</h1>

        <!-- Song Title -->
        <h2>Louka (Funkagenda Re-Edit)</h2>

         <!--Song Description(179 characters with spaces)-->
        <h4>I had to include this one since it literally took over control of me while driving the other morning. I was bouncing around in my seat like a little kid who desparately needs to use the bathroom. </h4> 

            <div class="buttons">
            <!--Song file info-->
            <div class="player">
            <a id="m85" class="audio {skin:'#010101',showVolumeLevel:false,showTime:false,showRew:false,ogg:'MP3/Adrian Lux feat. The Good Natured - Alive (Extended Mix).ogg'}" href="MP3/Adrian Lux feat. The Good Natured - Alive (Extended Mix).mp3"></a></div>


                <!--Download Link-->
                <div class="download">
                <a href="MP3/ThreeSixty, Funkagenda - Loudka (Funkagenda Re-Edit).mp3" title='Right Click and Save Link As'>
                <img src="img/dlicon.png"/></a>

                </div>
            </div>
        </div>

</div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暮倦 2025-01-03 09:26:22

我没有看到你的 jquery 中对 CSS 进行了任何更改。 CSS 本身并不动态地根据页面进行样式更改。当然它可以由 Jquery 或 php 操作,但我再次没有看到这一点。

I dont see any changes made to CSS in your jquery. CSS is not dynamic to style changes by itself based on pages. Sure it can be manipulated by Jquery or php, but again I dont see this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文