Search code examples
jqueryhtmlcsstwitter-bootstrapbxslider

I'd like to resize <div> area while an image is resized by "img-responsive" of Bootstrap


When I resize a browser, the images are resized. It is good because it is what I want to do. However, lower part of Black area does not resize. So in mobile browser, there is black area under the images. I'd like to fix it, but I have no idea what to do. Would you please give me advices?

My page is here.

{% load staticfiles %}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">  <!-- for IE --> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0"> 
    <title>Learning BxSlider</title>
    <link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" />
    <link href="{% static "bxslider/jquery.bxslider.css" %}" rel="stylesheet">
    <style type="text/css">
        body {
            color: red;
        }
        .container-fluid {
            margin: 0;
            padding: 0;
        }
        .row {
            margin: 0;
            padding: 0;
        }
        article#apple {
            width: 100%;
        }
        div#berry {
            height: 250px;
        }
        img.melon {
            display: block;  /* center */
            margin: auto;
        }
        .bxslider li {
            height: 250px;
        }
        h2.juice {
            position: relative;
            top: -250px;
            z-index: 10;
        }
        /*li#orange {
            background: center url("http://coolwebwindow.com/jquery-lab/wp-content/demo/bxslider_filter/images/photo01.jpg") no-repeat;
        }
        li#lemon {
            background: center url("http://coolwebwindow.com/jquery-lab/wp-content/demo/bxslider_filter/images/photo04.jpg") no-repeat;
        }*/
        .bx-wrapper .bx-viewport {  /* remove border */
            box-shadow: none;
            border: none;
            left: 0;
            right: 0;
            background-color: black;
        }
    </style>
</head>
<body>
    <section class="container-fluid">
        <article id="apple">
            <div class="row" id="berry">
                <ul class="bxslider">
                    <li id="orange" class="">
                        <img class="img-responsive melon" src="http://coolwebwindow.com/jquery-lab/wp-content/demo/bxslider_filter/images/photo01.jpg">
                        <h2 class="juice">Himawari</h2>
                    </li>
                    <li id="lemon" class="">
                        <img class="img-responsive melon" src="http://coolwebwindow.com/jquery-lab/wp-content/demo/bxslider_filter/images/photo04.jpg">
                        <h2 class="juice">Sumire</h2>
                    </li>
                </ul>  <!-- bxslider -->
            </div>
            <div>
                <span>BxSlider is difficult in Design</span>
            </div>
        </article>
    </section>


    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
    <script type="text/javascript" src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
    <script src="{% static "bxslider/jquery.bxslider.min.js" %}" type="text/javascript" ></script>
    <script type="text/javascript">
        $(function(){
            $('.bxslider').bxSlider({
                auto: true
            });
        });
    </script>

</body>
</html>

Using: Bootstrap, jQuery, BxSlider


Solution

  • remove height

    .bxslider li {
        height: 250px;
    }
    div#berry {
        height: 250px;
    }
    

    and it should work

    additionally you can use below code with replacement of ur existing h2.juice code this will remove remaining black space too

    h2.juice {
        position: absolute;
        z-index: 10;
        top: 50%;
        margin: 0;
        left: 20%;
    }
    

    don't forget too refresh your page see image for reference here