我想调整<div>区域的大小,同时通过Bootstrap的“img-responsive”调整图像大小

时间:2016-10-04 07:25:43

标签: jquery html css twitter-bootstrap bxslider

当我调整浏览器大小时,图像会调整大小。这很好,因为这是我想要做的。 但是,黑色区域的下半部分不会调整大小。因此在移动浏览器中,图像下方有黑色区域。我想解决它,但我不知道该怎么做。你能给我建议吗?

我的页面是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>

使用:BootstrapjQueryBxSlider

3 个答案:

答案 0 :(得分:1)

给予身高:100%;用于图像标记

答案 1 :(得分:1)

删除所有父元素的高度

 div#berry {
    /* height: 250px; */
 }

答案 2 :(得分:1)

删除身高

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

它应该有效

另外你可以使用下面的代码替换你现有的h2.juice代码,这也将删除剩余的黑色空间

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

不要忘记过刷新页面,请参阅图片以供参考here