使用Bootstrap Carousel的麻烦:图像不会根据容器大小调整大小

时间:2015-02-18 18:47:40

标签: html css twitter-bootstrap carousel

我在我的网站上使用Bootstrap。我的网站在桌面屏幕上有两列:我的内容的一个大区域,右侧的一个小区域,用于显示即将发生的事件的一些信息。当我使浏览器变小时,这两个区域很好地调整大小(变得更小),并且在某些时候,最右边的列跳到底部,就像响应的目的一样。 在我的主页上,我使用基于w3schools this example的轮播。 问题是旋转木马的图片根据列宽从不调整大小,它始终保持不变。在w3school示例中,您可以看到调整浏览器大小会导致调整图像大小。 我的HTML:

<!DOCTYPE html>
    <html lang="en">
    <head>
    <title>Home</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta charset="utf-8">
    <link rel='stylesheet' type='text/css' href='http://fonts.googleapis.com/css?family=Arimo:400,700'>
    <link rel="stylesheet" type='text/css' href="/Content/bootstrap.css" />
    <link rel="stylesheet" type='text/css' href="/Content/bootstrap-datepicker.css" />
    <link rel="stylesheet" type='text/css' href="/Content/NYC.css" />

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
    <script src="/Scripts/bootstrap-datepicker.js"></script>
    <script src="/Scripts/bootstrap.min.js"></script>
    <link href="/favicon.ico" rel="shortcut icon" type="image/x-icon" />

</head>
<body>
    <nav class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#"></a>
            </div>
            <div id="navbar" class="collapse navbar-collapse">
                <ul class="nav navbar-nav">
                    <li><a href="/">Home</a></li>
                    <li><a href="/Event">Agenda</a></li>

                    <li><a href="/Photo">Foto&#39;s</a></li>



                    <li><a href="/Contact">Contact</a></li>

                        <li><a href="/Account/Login">Login</a></li>
                                    </ul>
            </div> <!--/.nav-collapse -->
        </div>
    </nav>

    <div class="container">
        <div class="row">
            <div class="col-sm-8">


<header>
    <h2>Welkom</h2>
</header>



<div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="3000">
    <!-- Indicators -->
    <ol class="carousel-indicators">
        <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>

            <li data-target="#myCarousel" data-slide-to="1"></li>
            <li data-target="#myCarousel" data-slide-to="2"></li>
            <li data-target="#myCarousel" data-slide-to="3"></li>
            <li data-target="#myCarousel" data-slide-to="4"></li>

    </ol>

    <!-- Wrapper for slides -->
    <div class="carousel-inner" role="listbox">
        <div class="item active">

            <img src='https://farm8.staticflickr.com/7497/15440536044_ddb9b9a4f2_z.jpg' alt="Foto" >
            <div class="carousel-caption">
                <h2>Caption</h2>
                </div>
        </div>

            <div class="item">

                <img src='https://farm8.staticflickr.com/7542/15440460614_e147f37c21_z.jpg' alt="Foto">
                    <div class="carousel-caption">
                        <h2>Caption</h2>
                    </div>
            </div>
            <div class="item">

                <img src='https://farm8.staticflickr.com/7562/15761616062_9cd995c76f_z.jpg' alt="Foto">
                    <div class="carousel-caption">
                        <h2>Caption</h2>
                    </div>
            </div>
            <div class="item">

                <img src='https://farm3.staticflickr.com/2905/13976192867_78bd01faa1_z.jpg' alt="Foto">
                    <div class="carousel-caption">
                        <h2>Caption</h2>
                    </div>
            </div>
            <div class="item">

                <img src='https://farm4.staticflickr.com/3949/15574689588_2b427e30fa_z.jpg' alt="Foto">
                    <div class="carousel-caption">
                        <h2>Caption</h2>
                    </div>
            </div>
    </div><!-- /.carousel-inner -->

    <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
        <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
        <span class="sr-only">Previous</span>
    </a>
    <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
        <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
    </a>
</div><!-- /.carousel -->



            </div>


            <div class="col-sm-3 col-sm-offset-1">



<header>
    <h3>Vandaag</h3>
</header>


    <ul class="interestingevents">
        <li>
            <p class="posted">Niks te zien</p>
        </li>
    </ul>


<header>
    <h3>Komende evenementen</h3>
</header>

<ul class="interestingevents">

        <li>
            <a href='/Event/showEvent?eventID=13'>
                <p class="posted">
                    zondag 8 maart 2015
                </p>

                        <img src="/Content/Media/logosailing40x40.png" />


                <p class="text">
                    Winterwedstrijd
                    </p>
                <br/>
            </a>
        </li>
        <li>
            <a href='/Event/showEvent?eventID=20'>
                <p class="posted">
                    zaterdag 14 maart 2015
                </p>

                        <img src="/Content/Media/logogeneral40x40.png" />


                <p class="text">
                    Onderhoud infrastructuur
                    </p>
                <br/>
            </a>
        </li>
        <li>
            <a href='/Event/showEvent?eventID=21'>
                <p class="posted">
                    zondag 15 maart 2015
                </p>

                        <img src="/Content/Media/logogeneral40x40.png" />


                <p class="text">
                    Onderhoud infrastructuur
                    </p>
                <br/>
            </a>
        </li>

</ul>




<header>
    <h3>Gepasseerde evenementen</h3>
</header>

<ul class="interestingevents">
        <li>
            <p class="posted">
                zondag 8 februari 2015
            </p>


                    <img src="/Content/Media/logosailing40x40.png" />


            <p class="text">
                <a href='/Event/showEvent?eventID=12'>Winterwedstrijd</a>
            </p>
            <br />
        </li>
        <li>
            <p class="posted">
                zondag 18 januari 2015
            </p>


                    <img src="/Content/Media/logogeneral40x40.png" />


            <p class="text">
                <a href='/Event/showEvent?eventID=17'>Ledenvergadering</a>
            </p>
            <br />
        </li>
        <li>
            <p class="posted">
                zondag 4 januari 2015
            </p>


                    <img src="/Content/Media/logosailing40x40.png" />


            <p class="text">
                <a href='/Event/showEvent?eventID=10'>Winterwedstrijd</a>
            </p>
            <br />
        </li>
</ul>


            </div>

        </div>
    </div>




    <footer>
        <div id="copyright">
            <div class="container">
                <p>Created by </p>
            </div>
        </div>
    </footer>




<!-- Visual Studio Browser Link -->
<script type="application/json" id="__browserLink_initializationData">
    {"appName":"Firefox","requestId":"c3ad45de45c543c5bc071cf0007d01e5"}
</script>
<script type="text/javascript" src="http://localhost:60883/d9c407548b294087843ff4faeef78add/browserLink" async="async"></script>
<!-- End Browser Link -->

</body>
</html>

1 个答案:

答案 0 :(得分:1)

也许您可以尝试使用Bootstrap CDN链接:

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>

查看Bootstrap website