2

Twitter Bootstrrap でのカルーセルの使用に関する質問

私はTwitter Bootstrapの初心者です。今、自分のページにカルーセルを作成したいと考えています。しかし、私はいくつかの問題に遭遇しました。

まず、css ファイルで、カルーセルを中央に配置する場所が見つかりません。

次に、幅のキャプションをカルーセルの画像と同じにする方法がわかりません。

これが私のhtmlコードです:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Test</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <!-- Le styles -->
    <link href="rootfolder/bootstrap/docs/assets/css/bootstrap.css" rel="stylesheet">
    <link href="rootfolder/bootstrap/docs/assets/css/bootstrap-responsive.css" rel="stylesheet">
    <link href="rootfolder/bootstrap/docs/assets/css/docs.css" rel="stylesheet">
    <link href="rootfolder/bootstrap/docs/assets/js/google-code-prettify/prettify.css" rel="stylesheet">
    <link href="rootfolder/bootstrap/docs/assets/css/bootstrap-carousel.css" rel="stylesheet">
    <link href="rootfolder/css/temp.css" rel="stylesheet">

    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

    <!-- Le fav and touch icons -->
    <link rel="shortcut icon" href="assets/ico/favicon.ico">
    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="assets/ico/apple-touch-icon-144-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="assets/ico/apple-touch-icon-114-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
    <link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">

    <script type="text/javascript">
      $(function () {  
        $('.dropdown-toggle').dropdown();  
      });
    </script>

    <!--Lightbox--> 
    <script type="text/javascript">
      $(function () {  
        $('.carousel').carousel('cycle') 
      });
    </script>
  </head>

  <body data-spy="scroll" data-target=".subnav" data-offset="50">

  <!-- Navbar
================================================== -->
    <div class="navbar navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container">
          <button type="button"class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
              </button>
              <a class="brand" href="http://about.me/nienyiho">Nien-Yi Ho</a>
              <div class="nav-collapse collapse">
                <ul class="nav">
              <li class="dropdown" id="accountmenu">  
                <a class="dropdown-toggle" data-toggle="dropdown" href="#">About<b class="caret"></b></a>  
                <ul class="dropdown-menu">  
                  <li><a href="#">About Me</a></li>  
                </ul>  
              </li>
              <li class="">
                <a href="http://www.nienyiho.com/photography.html">Photography</a>
              </li>
              <li class="">
                <a href="http://www.nienyiho.com/articles.html">Articles</a>
              </li>
              <li class="">
                <a href="http://www.nienyiho.com/forsale.html">For Sale</a>
              </li>
              <li class="">
                <a href="http://nienyi.blogspot.tw">Blog</a>
              </li>
              <li class="">
                <a href="http://nienyi.blogspot.tw">Contact</a>
              </li>
              <li class="dropdown" id="accountmenu">  
                <a class="dropdown-toggle" data-toggle="dropdown" href="#">Tutorials<b class="caret"></b></a>  
            <ul class="dropdown-menu">  
              <li><a href="#">1</a></li>  
              <li><a href="#">2</a></li>  
              <li class="divider"></li>  
              <li><a href="#">3</a></li>  
              <li><a href="#">4</a></li>  
            </ul>  
          </li>
        </ul>
      </div>
    </div>
  </div>
</div>

<div class="container">

<!-- Masthead
================================================== -->
<header class="jumbotron masthead">

  <div class="inner">
    <p>Nien-Yi Ho Photography</p>
  </div>
</header>

  <!--測試Light Box-->

  <div id="myCarousel" class="carousel slide">
  <!-- Carousel items -->
    <div class="carousel-inner_test">
      <div class="active item">
        <img src="rootfolder/images/photography/all_time_collections/1.jpg" alt="" width="600" hight="900">
        <div class="carousel-caption">
          <h4>何去何從</h4>
          <p>台北 2008</p>
        </div>
      </div>

      <div class="item">
        <img src="rootfolder/images/photography/all_time_collections/2.jpg" alt="" width="600" hight="900">
        <div class="carousel-caption">
          <h4>撼動</h4>
          <p>2008 台大合唱團冬季公演&lt;/p>
        </div>
      </div>

      <div class="item">
        <img src="rootfolder/images/photography/all_time_collections/3.jpg" alt="" width="600" hight="900">
        <div class="carousel-caption">
          <h4>Height of the sky.</h4>
          <p>Paris 2002</p>
        </div>
      </div>
    </div>
  <!-- Carousel nav -->
  <a class="carousel-control left" href="#myCarousel" data-slide="prev">&lsaquo;</a>
  <a class="carousel-control right" href="#myCarousel" data-slide="next">&rsaquo;    </a>
  </div>

     <!-- Footer
  ================================================== -->
      <footer class="footer">
        <p>Powered by <a href="http://twitter.github.com/bootstrap/" target="_blank">Twitter Bootstrap</a> </p>
      </footer>

    </div><!-- /container -->

        <!-- Le javascript
================================================== -->
        <!-- Placed at the end of the document so the pages load faster -->
    <script type="text/javascript" src="http://platform.twitter.com/widgets.js">    </script>
    <script type="text/javascript" src="rootfolder/bootstrap/docs/assets/js/jquery.js"></script>
    <script type="text/javascript" src="rootfolder/bootstrap/docs/assets/js/google-code-prettify/prettify.js"></script>
    <script type="text/javascript" src="rootfolder/bootstrap/docs/assets/js/bootstrap-transition.js"></script>
    <script type="text/javascript" src="rootfolder/bootstrap/docs/assets/js/bootstrap-alert.js"></script>
    <script type="text/javascript" src="rootfolder/bootstrap/docs/assets/js/bootstrap-modal.js"></script>
    <script type="text/javascript" src="rootfolder/bootstrap/docs/assets/js/bootstrap-dropdown.js" type="text/javascript"></script>
    <script type="text/javascript" src="rootfolder/bootstrap/docs/assets/js/bootstrap-scrollspy.js"></script>
    <script type="text/javascript" src="rootfolder/bootstrap/docs/assets/js/bootstrap-tab.js"></script>
    <script type="text/javascript" src="rootfolder/bootstrap/docs/assets/js/bootstrap-tooltip.js"></script>
    <script type="text/javascript" src="rootfolder/bootstrap/docs/assets/js/bootstrap-popover.js"></script>
    <script type="text/javascript" src="rootfolder/bootstrap/docs/assets/js/bootstrap-button.js"></script>
    <script type="text/javascript" src="rootfolder/bootstrap/docs/assets/js/bootstrap-collapse.js"></script>
<script type="text/javascript" src="rootfolder/bootstrap/docs/assets/js/bootstrap-carousel.js"></script>
    <script type="text/javascript" src="rootfolder/bootstrap/docs/assets/js/bootstrap-typeahead.js"></script>
    <script type="text/javascript" src="rootfolder/bootstrap/docs/assets/js/application.js"></script>

  </body>
</html>
4

1 に答える 1

2

カルーセルを真ん中に置くには、次のことができます。

CSS クラスを変更します。

carousel-inner_test to just carousel-inner

次に #myCarousel 要素に追加します。

width: 600px;
margin: 0px auto;   

キャプションの問題も解決するはずです。

HTH

于 2012-06-28T08:58:12.940 に答える