-1

I have this problem where I'm making an inner box (div) to the left or the right of each slide, with some text. This is easy to do and style, but the problem is that for some reason the Previous arrow and the Next arrow position themselves again inside of the secondary/inner div, as the attached pictures illustrate. enter image description here enter image description here

Here is sample html, which comprises the slide sections corresponding to the example images:

  <div class="slide" id="slide2">
    <div class="band band-right red">
      <a href="/why-go-tec/" class="slider" ><h1 class="banner">Your Food Never Tasted This Good</h1></a>
      <a href="/why-go-tec/" class="slider" ><h2 class="banner">EXPERIENCE THE 100% INFRARED DIFFERENCE</h2></a>
    </div>
  </div>

  <div class="slide" id="slide3">
    <div class="band band-right slate">
      <a href="/performance-guarantee/" class="slider" ><h1 class="banner">TEC Owners Love Their Grills</h1></a>
      <a href="/performance-guarantee/" class="slider" ><h2 class="banner">WE WANT YOU TO LOVE YOURS TOO - OUR 30-DAY MONEY BACK GUARANTEE</h2></a>
    </div>
  </div>  

My need is to show only the two arrows on either end of the main div, and eliminate the second pair of arrows that show within the smaller solid colored rectangle.

This is the link to the page I'm working on: BX Slider page

TARKUS
  • 2,170
  • 5
  • 34
  • 52
  • 1
    Do you have a demo on [jsFiddle](https://jsfiddle.net)? I'd like to see your jQuery for the bxSlider plugin. HTML is not enough info to assess your problem. – zer00ne Jul 21 '15 at 23:02
  • Can't do a Fiddle, but I added a link to the main post. – TARKUS Jul 21 '15 at 23:23

2 Answers2

1

Ok, instead of worrying about WordPress's quirks, I'll give you an example of a Dual Flex-bxSlider and walk through the important parts.

  • The two divs .bxRight and .bxLeft are the children of the flex container .bxMain. This flexbox layout is responsive and has the potential to change other ways like stack into a column without any JS/jQuery. I only did some basic flexbox, if you want more info go here.
  • Back to those two divs .bxRight and .bxLeft, they are the containers for the two bxSliders: .mxDisplay and .txBoard
    • .bxRight .txBoard
    • .bxLeft .mxDisplay
  • I gave .txBoard controls: true and .mxDisplay controls: false, then using bxSlider's callbacks, I slaved .mxDisplay's actions to .txBoard's actions:

    • Both bxSliders have: onSlideNext: moveBX, and onSlidePrev: moveBX, callbacks.
    • So moveBX() is called on every slide movement:

      function moveBX($ele, from, to) { mx.goToSlide(to); tx.goToSlide(to); }

  • The last important detail is the buttons, which there is now only one pair that controls both bxSliders simultaneously (well technically not really, but to the naked eye it is.) To take control of the buttons' appearance and positioning, I did the following:

        nextSelector: '.bxRBtn',
        prevSelector: '.bxLBtn',
        nextText: '►',
        prevText: '◄'
    

Go to bx Options for the full details. The demo is kinda raw style-wise (wrote it in a rush) so I'll leave the aesthetics to you. If this isn't what your'e looking for, let me know and furnish me more details. Good luck, sir. DEMO

CSS

.bxMain {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-wrap: nowrap;
    flex-wrap: nowrap;
    -webkit-justify-content: stretch;
    justify-content: stretch;
    -webkit-align-content: center;
    align-content: center;
    -webkit-align-items: center;
    align-items: center;
}
.bxLeft {
    float: left;
    width: 100%;
    height: 100%;
    min-height: 390px;
    -webkit-order: 0;
    order: 1;
    -webkit-flex: 0 1 50%;
    flex: 0 1 50%;
    -webkit-align-self: stretch;
    align-self: stretch;
}
.bxRight {
    float: left;
    width: 100%;
    height: 100%;
    min-height: 390px;
    -webkit-order: 2;
    order: 2;
    -webkit-flex: 0 1 50%;
    flex: 0 1 50%;
    -webkit-align-self: stretch;
    align-self: stretch;
}
.bxLBtn, .bxRBtn {
    position: absolute;
    z-index: 999;
}
.bx-prev, .bx-next {
    font-size: 48px;
    font-family: Times;
    color: blue;
    text-decoration: none;
}
.bxLBtn {
    left: 0;
    top: 50%;
}
.bxRBtn {
    right: 0;
    top: 50%;
}

HTML

<section id="bxShell">


  <main class="bxMain">
  <div class="bxLeft">
    <ul class="mxDisplay">
      <li>
        <img src="https://placehold.it/670x630/000/fff.png&text=SLIDE+1">
      </li>
      <li> <p>N'ghft n'gha naflnilgh'ri llll stell'bsna Dagon kn'a ron ahog naflilyaa naflNyarlathotep, ebunma y'hah li'hee tharanakoth ngshagg chtenff gnaiih ehye lw'nafhoth geb, uaaah shtunggli cgeb llll mg sll'hanyth nog Yoggoth naflfm'latgh.</p> </li>
      <li>
        <img src="https://placehold.it/670x630/fff/000.png&text=SLIDE+3">
      </li>

    </ul>
  </div>
  <div class="bxLBtn"></div>
<div class="bxRBtn"></div>
  <div class="bxRight">
    <ul class="txBoard">
      <li>
        <p> Stell'bsna f'li'hee kn'a nglui hai bug vulgtlagln shtunggli ya k'yarnak, Azathoth y-ron Hastur tharanak 'fhalma Chaugnar Faugn fm'latgh lw'nafh 'fhalma nanw, tharanak ehye nilgh'ri nnnfhtagn vulgtm Hasturoth shugg y'hah. 
          Grah'n vulgtm sgn'wahl hlirgh syha'h hlirgh nw 'ai stell'bsna kn'a ngah shagg, zhro f'vulgtlagln y-ee nnnehye tharanak s'uhn y-uln cgof'nn ebunma gotha fhtagn, Chaugnar Faugn lw'nafh Chaugnar Faugn sgn'wahl h'gof'nn syha'hog nog czhro Hastur mnahn'. 
          Shub-Niggurath ehye fm'latgh uh'e h'gof'nn wgah'n hlirghog nalw'nafh Hastur stell'bsna ehyeagl kn'aoth cooboshu, uaaah s'uhn zhro gnaiih 'bthnk shtunggli ngli'hee ya ftaghu mnahn' cllll, Nyarlathotep s'uhn uh'e shagg gnaiih phlegeth ooboshu bug athg kadishtu chtenff. </p>
      </li>
            <li>
        <img src="https://placehold.it/670x630/ff8cff/00df00.png&text=SLIDE+2">
      </li>
      <li>
        <p> Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn. Uh'e nnnfhtagn, ilyaaagl li'hee gof'nn li'hee uln ooboshu, gof'nn Dagon phlegeth sll'ha tharanak ronor. 
          Ph'ch' naflhai naflnglui hrii ah mg k'yarnak clw'nafh, s'uhn gnaiih naflDagon naflathg ebunma ngy'hah 'bthnk ep, throdnyth ftaghu n'gha R'lyeh n'ghaor y-gotha. 
          Ngkadishtu ngfhtagn ehye uln zhro ya Dagon zhro Chaugnar Faugn r'luh sgn'wahl vulgtm nilgh'ri, h'ron llll vulgtmyar shugg syha'h uh'e ron chtenff k'yarnak naflphlegeth nnnah. 
          Ep shugg naflTsathoggua zhro nnnooboshu ah shugg naflehye throd, nw naflnglui fhtagn Dagon mnahn' shagg ebunma hupadgh ebunma, k'yarnak uaaahor Dagon ooboshu vulgtm athg cCthulhu. </p>
      </li>

    </ul>
  </div>
  </main>
</section>

jQuery

$(function() {
    var mx = $('.mxDisplay').bxSlider({
        pager: false,
        controls: false,
        onSlideNext: moveBX,
        onSlidePrev: moveBX,
        adaptiveHeight: true
    });

    var tx = $('.txBoard').bxSlider({
        pager: false,
        onSlideNext: moveBX,
        onSlidePrev: moveBX,
        nextSelector: '.bxRBtn',
        prevSelector: '.bxLBtn',
        nextText: '►',
        prevText: '◄',
                adaptiveHeight: true
    });
    function moveBX($ele, from, to) {
        mx.goToSlide(to);
        tx.goToSlide(to);
    }
});
zer00ne
  • 41,936
  • 6
  • 41
  • 68
0

After pulling on the ball of thread, and using Firefox's developer inspector to see what the names of the elements are used to form and contain the prev-next arrows, I pinpointed the problem to be in this section of the jquery.bxslider.js. I commented out two lines, and just changed the class that I want the PREV and NEXT arrows appended to the wide "slide" class (look near the bottom of the following code):

     /**
     * Appends prev / next controls to the controls element
     */
    var appendControls = function(){
        //slider.controls.next = $('<a class="bx-next" href="">' + slider.settings.nextText + '</a>');
        //slider.controls.prev = $('<a class="bx-prev" href="">' + slider.settings.prevText + '</a>');
        slider.controls.next = $('<a class="bx-next" href=""><img src=\"images/next30.png\"></</a>');
        slider.controls.prev = $('<a class="bx-prev" href=""><img src=\"images/prev30.png\"></a>');

        // bind click actions to the controls
        slider.controls.next.bind('click', clickNextBind);
        slider.controls.prev.bind('click', clickPrevBind);
        // if nextSlector was supplied, populate it
        if(slider.settings.nextSelector){
            $(slider.settings.nextSelector).append(slider.controls.next);
        }
        // if prevSlector was supplied, populate it
        if(slider.settings.prevSelector){
            $(slider.settings.prevSelector).append(slider.controls.prev);
        }
        // if no custom selectors were supplied
        if(!slider.settings.nextSelector && !slider.settings.prevSelector){
            // add the controls to the DOM
            slider.controls.directionEl = $('<div class="bx-controls-direction" />');
            // add the control elements to the directionEl
            slider.controls.directionEl.append(slider.controls.prev).append(slider.controls.next);
            /* I commented out the following line: */
            //slider.viewport.append(slider.controls.directionEl);
            /* I ADDED this line. The divs with the class "slide" are the main, wide divs, where I want the arrows to be on either end: */
            $(".slide").append(slider.controls.directionEl);
            /* I commented out the following line: */
            //slider.controls.el.addClass('bx-has-controls-direction').append(slider.controls.directionEl);
        }
    }

One more thing I had to do was to fiddle with the vertical positioning of the arrows so they wouldn't overlap the vertically centered text, but more importantly, I added a high z-index to the bx-prev and bx-next classes, so that the arrows will always show in the top-most layer, and not be hidden under any secondary rectangles I place within the slide:

a.bx-prev{
    position:absolute;
    top:100%;
    margin-top:-35px;
    left:10px;
    margin-left:0px;
    z-index:10;
}
a.bx-next{
    position:absolute;
    top:100%;
    margin-top:-35px;
    left:100%;
    margin-left:-40px;
    z-index:10;
}
TARKUS
  • 2,170
  • 5
  • 34
  • 52