BX-Slider allows for the insertion of Prev and Next Arrows in both the Main Div and Inner Divs

I am facing an issue with positioning inner boxes (divs) to the left or right of each slide while adding some text. Although styling them is easy, the problem arises when the Previous and Next arrows appear inside the secondary/inner div, as shown in the attached images.

Below is a snippet of HTML code representing 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 goal is to display only the two arrows at either end of the main div, while removing the duplicate pair that appears within the smaller colored rectangle.

You can view the page I am working on through the following link: BX Slider page

Answer №1

Instead of getting caught up in WordPress's idiosyncrasies, let me provide you with an example of a Dual Flex-bxSlider and guide you through the key components.

  • The flex container .bxMain has two child divs: .bxRight and .bxLeft. This flexible layout is responsive and can adapt in various ways, like stacking into a column without any JS/jQuery intervention. For more comprehensive information on flexbox, refer to this resource.
  • Within these divs are containers for two bxSliders: .mxDisplay and .txBoard.
    • .bxRight .txBoard
    • .bxLeft .mxDisplay
  • I have enabled controls for .txBoard (controls: true) and disabled them for .mxDisplay (controls: false). By utilizing bxSlider callbacks, I synchronized actions between .mxDisplay and .txBoard:

    • Both bxSliders utilize the onSlideNext: moveBX, and onSlidePrev: moveBX, callbacks.
    • The function moveBX() gets invoked with every slide movement:

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

  • Another crucial detail pertains to the buttons; now there is only one set controlling both bxSliders simultaneously (from a visual standpoint). To customize button appearance and placement, I implemented the following:

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

Visit bx Options for complete details. The demo may lack polish style-wise (created it hastily), so I'll leave the aesthetics up to you. If this doesn't meet your requirements, feel free to provide additional details. Good luck! 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;
}

/* Additional CSS rules omitted for brevity */

HTML

<section id="bxShell">


  <main class="bxMain">
  <div class="bxLeft">

  /* Content within bxLeft omitted for brevity */

  </div>

  /* Buttons markup also omitted for brevity */

  <div class="bxRight">

   /* Content within bxRight omitted for brevity */

  </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);
    }
});

Answer №2

Upon unraveling the thread of code and utilizing Firefox's developer inspector to reveal the underlying elements responsible for forming and housing the prev-next arrows, I deduced that the issue lied within this specific segment of the jquery.bxslider.js file. By omitting two lines and modifying the class where the PREV and NEXT arrows are to be appended to the broad "slide" class (located towards the end of the code snippet below):

     /**
     * 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);
        }
    }

To ensure the arrows did not overlap with vertically centered text, adjustments to their vertical positioning were necessary. Furthermore, a significant z-index was assigned to the bx-prev and bx-next classes to guarantee the arrows always displayed at the forefront without being concealed beneath any supplementary shapes inserted 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;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Leveraging Facebook Pixel within a DNN-powered website

Is there a way to integrate the Facebook pixel into a website created using the DNN platform? ...

Mastering linear regression calculations using vue.js and chart.js

Take for instance, with the current dataset, I am looking to showcase a linear regression I managed to do this in Vista and now I need guidance on how to proceed with the calculation. I am not too familiar with using the formula Here is my HTML: <canva ...

Discovering whether a link has been clicked on in a Gmail email can be done by following these steps

I am currently creating an email for a marketing campaign. In this email, there will be a button for users to "save the date" of the upcoming event. I would like to implement a feature that can detect if the email was opened in Gmail after the button is cl ...

Is there a way to reset a state without needing to declare an initialState beforehand?

I'm facing a situation where I need to reset a state without having to create an initial state again. Here's the dilemma: initialState: { id: '', name: '', index: '' }, state: { ...

What is the best way to determine the dimensions of a KonvaJs Stage in order to correctly pass them as the height/width parameters for the toImage function

Currently, I am using KonvaJs version 3.2.4 to work with the toImage function of the Stage Class. It seems that by default, toImage() only captures an image of the visible stage area. This is why there is a need to provide starting coordinates, height, and ...

Transform an HTML website into a collaborative wiki platform

I currently have a simple HTML website (no JavaScript, PHP, or CSS) with over 1000 pages that I want to transform into a Wiki format. I need a converter to extract the content from each page and create individual wiki pages for them. Additionally, all the ...

What could be the reason for an ASP.NET Core application not loading within an iframe on the same domain?

I am facing an issue with my ASP.NET Core MVC website, which is embedded as the src of an IFRAME within a portal. Both the portal and the .NETCore application share the same domain (e.g., site.portal.domain / portal.domain). Upon entering the portal, I en ...

React Div Element Not Extending to Web Page Margin

creating white space between the green div and both the top and sides of the screen This is my index page export default function Home() { return( <div className = {stylesMain.bodyDiv}> <div>home</div> &l ...

A quicker method for setting the emitted value to data

Is there a way to pass data from child to parent without creating a method for assigning the value? I want to be able to assign it directly in the template. This is my current code: Child <h1 @click="$emit('title', 'Home')&quo ...

Conceal your password using HTML techniques

My goal is to hide passwords from being visible unless a user hovers directly over them. I've tried using the code below, but the hover effect isn't working as expected - either the password disappears completely or remains visible at all times. ...

The JSON creation response is not meeting the expected criteria

Hello, I'm currently working on generating JSON data and need assistance with the following code snippet: generateArray(array) { var map = {}; for(var i = 0; i < array.length; i++){ var obj = array[i]; var items = obj.items; ...

How can I show a loading screen while making a synchronous AJAX call in Chrome?

Is there any method to show a loading screen in Chrome while using async:false in an AJAX call? The use of setTimeout poses several challenges when making multiple synchronous AJAX calls within the setTimeout function. Additionally, the loading indicator ...

Unique key press responses for various key press events result in different actions being taken. Wondering how to achieve this? Explore

As a newbie to JavaScript, I have a question regarding multiple keypress events and how to assign them to different actions. Here is the code snippet: var imga = ["http://img1.jpegbay.com/gallery/004236128/1_t.jpg", "http://img1.jpegbay.com/gallery/0042 ...

Updating documents in a mongoDB collection can be done by simply

I require an update to my database that will modify existing data, as illustrated below: existing data => [{_id:"abnc214124",name:"mustafa",age:12,etc...}, {_id:"abnc21412432",name:"mustafa1",age:32,etc...}, {_id ...

jquery: conditions fail to execute

Looking at the code snippet provided, it appears quite straightforward. The intention is to display an alert labeled "Trigger 2" if the variable "ret" returns a value of "fail". However, there seems to be a glitch with the IF statement causing it to trigge ...

Should medium-sized JavaScript arrays be compressed before sending them to the client via a socket?

I find myself considering whether it would be beneficial to use compression when sending medium sized arrays, containing small strings and numbers, from nodejs with socket.io to clients. The arrays are less than 1 MB in size. Would the time spent compressi ...

Creating a dynamic HTML table in Django by populating it with values from iterative lists

Currently, in the Django framework, I am endeavoring to construct a table using the values stored within a list: List : [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [3, 3, 3, 3]]. The envisioned table layout is as follows: Below is the code snippet that ...

The function generalChannel.send does not exist

I've recently started working on a discord bot and I'm facing an issue with getting it to greet everyone when it's turned on. Using the bot.channels.get method, I am able to locate the channel successfully, but when it comes to sending a mes ...

Updating the Bootstrap entry dynamically within the @NgModule module

My web application has a specific requirement where it can only be accessed through example.com/index.html without any parameters. The backstory behind this restriction is quite lengthy, so let's not delve into that. Within the index.html file, I have ...

Retrieving the $scope data from within an http.get callback

Would someone be able to assist me with storing the data returned by the $http.get function in a $scope variable for use in my ui-grid control? I have tried the code below but seem to be missing something simple. I just can't figure out what it is: ...