2016-11-17 17 views
1

ブートストラップ(下のリンクのcodepen)から半ページの背景スライダーテンプレートを採用したいのですが、背景画像のサイズが変更されないため、それに応じて。 half-slider.cssの高さと重さの設定についての説明は非常に高く評価されます。私は、ページの残りの部分のサイズが変更されたとして半分スライダー写真のサイズを変更しようとしている理由であるモバイルやタブレットデバイス上の風景の景色を写真の上部うちブートストラップのハーフスライダーカルーセル画像を反応させる

http://codepen.io/kli96/pen/eBBmKB

現在の実装ブロック。

<html lang="en"> 

<head> 

<meta charset="utf-8"> 
<meta http-equiv="X-UA-Compatible" content="IE=edge"> 
<meta name="viewport" content="width=device-width, initial-scale=1"> 
<meta name="description" content=""> 
<meta name="author" content=""> 

<title>Half Slider - Start Bootstrap Template</title> 


</head> 

<body> 

<!-- Navigation --> 
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation"> 
    <div class="container"> 
     <!-- Brand and toggle get grouped for better mobile display --> 
     <div class="navbar-header"> 
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> 
       <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="#">Start Bootstrap</a> 
     </div> 
     <!-- Collect the nav links, forms, and other content for toggling --> 
     <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> 
      <ul class="nav navbar-nav"> 
       <li> 
        <a href="#">About</a> 
       </li> 
       <li> 
        <a href="#">Services</a> 
       </li> 
       <li> 
        <a href="#">Contact</a> 
       </li> 
      </ul> 
     </div> 
     <!-- /.navbar-collapse --> 
    </div> 
    <!-- /.container --> 
</nav> 

<!-- Half Page Image Background Carousel Header --> 
<header id="myCarousel" class="carousel slide"> 
    <!-- Indicators --> 
    <ol class="carousel-indicators"> 
     <li data-target="#myCarousel" 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> 
    </ol> 

    <!-- Wrapper for Slides --> 
    <div class="carousel-inner"> 
     <div class="item active"> 
      <!-- Set the first background image using inline CSS below. --> 
      <div class="fill" style="background-image:url('http://placehold.it/1900x1080&text=Slide One');"></div> 
      <div class="carousel-caption"> 
       <h2>Caption 1</h2> 
      </div> 
     </div> 
     <div class="item"> 
      <!-- Set the second background image using inline CSS below. --> 
      <div class="fill" style="background-image:url('http://placehold.it/1900x1080&text=Slide Two');"></div> 
      <div class="carousel-caption"> 
       <h2>Caption 2</h2> 
      </div> 
     </div> 
     <div class="item"> 
      <!-- Set the third background image using inline CSS below. --> 
      <div class="fill" style="background-image:url('http://placehold.it/1900x1080&text=Slide Three');"></div> 
      <div class="carousel-caption"> 
       <h2>Caption 3</h2> 
      </div> 
     </div> 
    </div> 

    <!-- Controls --> 
    <a class="left carousel-control" href="#myCarousel" data-slide="prev"> 
     <span class="icon-prev"></span> 
    </a> 
    <a class="right carousel-control" href="#myCarousel" data-slide="next"> 
     <span class="icon-next"></span> 
    </a> 

</header> 

<!-- Page Content --> 
<div class="container"> 

    <div class="row"> 
     <div class="col-lg-12"> 
      <h1>Half Slider by Start Bootstrap</h1> 
      <p>The background images for the slider are set directly in the HTML using inline CSS. The rest of the styles for this template are contained within the <code>half-slider.css</code>file.</p> 
     </div> 
    </div> 

    <hr> 

    <!-- Footer --> 
    <footer> 
     <div class="row"> 
      <div class="col-lg-12"> 
       <p>Copyright &copy; Your Website 2014</p> 
      </div> 
     </div> 
     <!-- /.row --> 
    </footer> 

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

<!-- jQuery --> 
<script src="js/jquery.js"></script> 

<!-- Bootstrap Core JavaScript --> 
<script src="js/bootstrap.min.js"></script> 

<!-- Script to Activate the Carousel --> 
<script> 
$('.carousel').carousel({ 
    interval: 5000 //changes the speed 
}) 
</script> 

と、対応するCSS:)

1ウルナビゲーションバーに固定されたトップクラスを作成します。

html, 
body { 
    height: 100%; 
} 

.carousel { 
    height: 50%; 
} 

.item, 
.active, 
.carousel-inner { 
    height: 100%; 
} 

.fill { 
    width: 100%; 
    height: 100%; 
    background-position: center; 
    -webkit-background-size: cover; 
    -moz-background-size: cover; 
    background-size: cover; 
    -o-background-size: cover; 
} 

footer { 
    margin: 50px 0; 
} 
+0

はflunkerでコードを共有したり、私たちはウル裁判のプレビューを表示するためcodepen。私たちはより良い提案をすることができます。 – Smit

+0

申し訳ありません、前に間違ったリンクを投稿しました - ちょうどコードを追加しました –

答えて

0

オーケーあなたはおそらく2つの方法は、この問題を解決していますposition: relative

OR

2)ウルカルーセルクラスにマージンを追加margin-top: 1%;

+1

ありがとう!ポジションの相対的なトリックでした。私は補償するためにカルーセルをシフトしなければならなかったが、風景のモバイルビューでは今は完璧に見える。 –

関連する問題