Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bxSlider & Bootstrap 3 - Percentage slideWidth

I am using Bootstrap 3 on a website and I want to display two columns at a time with a bxSlider ticker, however the slideWidth parameter requries an absolute width and this is not possible as I am using percentages within BS's predefined CSS.

I have been searching around and can't seem to find anything on the subject.

This is the HTML:

    <div class="row">
        <ul class="cs-ticker">
            <li>
                <div class="col-lg-6 col-md-6">
                    <div class="image">
                        <a href=""><img src="images/cs-1.jpg" alt="" class="img-responsive" /></a>
                        <div class="overlay">
                            <h3><a href="">Case Study Title</a></h3>
                            <a href="" class="btn btn-outline btn-lg btn-white">View Case Study</a>
                        </div>
                        <span class="label">Residential</span>
                    </div>
                    <p>Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Cras mattis consectetur purus sit amet fermentum. Vestibulum id ligula porta felis euismod semper.</p>
                </div>
            </li>
            <li>
                <div class="col-lg-6 col-md-6">
                    <div class="image">
                        <a href=""><img src="images/cs-1.jpg" alt="" class="img-responsive" /></a>
                        <div class="overlay">
                            <h3><a href="">Case Study Title 2</a></h3>
                            <a href="" class="btn btn-outline btn-lg btn-white">View Case Study</a>
                        </div>
                        <span class="label">Commercial</span>
                    </div>
                    <p>Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Cras mattis consectetur purus sit amet fermentum. Vestibulum id ligula porta felis euismod semper.</p>
                </div>
            </li>                   
        </ul>
    </div>

    <script>
        $(document).ready(function(){

            var CaseStudyTicker = $('#recent-case-studies .cs-ticker');
            var CaseStudyTickerOpts = {
                auto: false,
                speed: 700,
                controls: true,
                pager: false,
                responsive: false,
                maxSlides: 2,
                minSlides: 2,
                adaptiveHeight: false
            };

            if( isMobile.any() ) {
                CaseStudyTickerOpts.controls = false;
            }

            //CaseStudyTicker.bxSlider(CaseStudyTickerOpts);

        });
    </script>

Ignore the isMobile bit as that is separate..

Basically I'm thinking that the width needs to get set onSliderLoad and when the window resizes the width needs to reset?

like image 592
Nathan Fitzgerald - Fitzgenius Avatar asked Apr 25 '14 14:04

Nathan Fitzgerald - Fitzgenius


People also ask

What is buzzbxslider?

bxslider is a fully responsive jQuery Slider Plugin that allows you to create a content slider which can contain images, video, or HTML content. Uses CSS transitions for slide animation (native hardware acceleration!)

What is “bxslider for WordPress”?

“bxSlider for WordPress” is open source software. The following people have contributed to this plugin. Translate “bxSlider for WordPress” into your language. Interested in development?

What's new in bxslider?

Added bower.json configuration file. Manage bxSlider as a dependency using bower. Removed imagesLoaded library and added iframe preloading support Added responsive option - setting to false will prevent $ (window).resize binding Carousel mode (minSlides / maxSlides) was re-written to be more intuitive.

How to make a slider using jQuery?

bxslider is a fully responsive jQuery Slider Plugin that allows you to create a content slider which can contain images, video, or HTML content. Uses CSS transitions for slide animation (native hardware acceleration!) 1. Include necessary files 2. Html Markup 3. Call the plugin 4. Options and defaults. Added data reference.


2 Answers

There is a bootstrap friendly version of bxslider I forked on github that will automatically calculate the required slide widths to fit the number of visible slides you desire. It will also adapt the values to any screen.

I think this version will solve all your problems.

Link>> https://github.com/Rahisify/bxslider-4

like image 174
Arnique Avatar answered Sep 30 '22 14:09

Arnique


If you enter a width that it too high, bxSlider will calculate the maximum width automatically for you. So if you container is 900px, your slideWidth is 900, and you have 3 slides, bxSlider will set the width of each slide to 300px.

like image 45
Michiel Avatar answered Sep 30 '22 12:09

Michiel