2017-06-26 12 views
0

私はブートストラップのウェルを使ってカードに似ています。私は現在、画面の中央にある「通常の」カードと、左右にある「特別なカード」の2種類のカードを持っています。私は複製しようとしているページの左側と右側にブートストラップのウェルを表示

テンプレート:

template

問題:

1)ブートストラップのウェルは非常に行きたくないように思えページの左または右。彼らは目に見えないdiv/borderに常に含まれているように見え、絶対位置指定が使われていなければどこにも行きません。ズームインすると中間のコンテンツが重なって絶対的な位置付けをすることはできません。それは、滞在する必要のあるブートストラップの反応的な面を取り除きます。

2)絶対位置を使用せず、側に新たに「特別な」カードを作ることはページ

body { 
 
    background-color: #5C67B6; 
 
} 
 

 
html, 
 
body { 
 
    height: 100%; 
 
    padding-top: 70px; 
 
} 
 

 
.btn-purple { 
 
    color: #fff; 
 
    background-color: #5C67B6; 
 
    border-color: #5C67B6; 
 
    position: absolute; 
 
    bottom: 30px; 
 
    left: 50%; 
 
    margin-left: -140px; 
 
} 
 

 
.btn-info { 
 
    color: #fff; 
 
    background-color: #5C67B6; 
 
    border-color: #5C67B6; 
 
    position: absolute; 
 
    bottom: 30px; 
 
    right: 10%; 
 
    margin-left: 140px; 
 
} 
 

 
.btn-info:hover, 
 
.btn-info:focus, 
 
.btn-info:active, 
 
.btn-info.active, 
 
.open>.dropdown-toggle.btn-info { 
 
    color: #fff; 
 
    background-color: #4b5496; 
 
    border-color: #4b5496; 
 
} 
 

 
.btn-purple:hover, 
 
.btn-purple:focus, 
 
.btn-purple:active, 
 
.btn-purple.active, 
 
.open>.dropdown-toggle.btn-purple { 
 
    color: #fff; 
 
    background-color: #4b5496; 
 
    border-color: #4b5496; 
 
} 
 

 
.customClass { 
 
    width: 700px; 
 
    max-width: 100%; 
 
    margin: 0px auto; 
 
} 
 

 
.turbo { 
 
    background: #7280e5; 
 
    color: white; 
 
    border-color: #4b5496; 
 
} 
 

 
.well { 
 
    min-height: 320px; 
 
    max-height: 320px; 
 
    height: auto; 
 
    overflow-wrap: break-word; 
 
    word-wrap: break-word; 
 
    hyphens: auto; 
 
} 
 

 
.well:hover { 
 
    background: #7280e5; 
 
    color: white; 
 
    border-color: #4b5496; 
 
} 
 

 
.well p { 
 
    margin-bottom: 50px; 
 
} 
 

 
.header { 
 
    display: inline-block; 
 
    width: 100%; 
 
    border: 1px solid red; 
 
} 
 

 
.playerOne { 
 
    float: right; 
 
    text-align: center; 
 
    width: 300px; 
 
    border: 5px solid #dadada; 
 
    background-color: #dadada; 
 
    border-radius: 5px; 
 
    -webkit-border-radius: 4px; 
 
    -moz-border-radius: 4px; 
 
    border-radius: 4px; 
 
    -webkit-box-shadow: 0px 0px 15px #5dbcd2; 
 
    -moz-box-shadow: 0px 0px 15px #5dbcd2; 
 
    box-shadow: 0px 0px 15px #5dbcd2; 
 
} 
 

 
.playerTwo { 
 
    float: left; 
 
    text-align: center; 
 
    width: 300px; 
 
    border: 5px solid #dadada; 
 
    background-color: #dadada; 
 
    border-radius: 5px; 
 
    -webkit-border-radius: 4px; 
 
    -moz-border-radius: 4px; 
 
    border-radius: 4px; 
 
    -webkit-box-shadow: 0px 0px 15px #5dbcd2; 
 
    -moz-box-shadow: 0px 0px 15px #5dbcd2; 
 
    box-shadow: 0px 0px 15px #5dbcd2; 
 
} 
 

 
@media only screen and (max-width: 900px) { 
 
    .playerOne { 
 
    width: 650px; 
 
    } 
 
    .playerTwo { 
 
    width: 633px; 
 
    } 
 
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" /> 
 
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" /> 
 
<div class="header"> 
 
    <div class="playerOne"> 
 
    Special Cards 
 
    </div> 
 
    <div class="playerTwo"> 
 
    Special Cards 
 
    </div> 
 
</div> 
 

 
<center> 
 
    <div class="input-group" style="width: 500px; padding-bottom: 2cm;"> 
 
    <input type="text" class="form-control" placeholder="Search cards!"> 
 
    <span class="input-group-btn"> 
 
     <button class="btn btn-default" type="button">Go!</button> 
 
     </span> 
 
    </div> 
 
    <!-- /input-group --> 
 
</center> 
 
<div class="content"> 
 
    <div class="container content-sm customClass"> 
 
    <div class="row"> 
 
     <center> 
 
     <nav aria-label="Page navigation"> 
 
      <ul class="pagination"> 
 
      <li> 
 
       <a aria-label="Previous" href="#"><span aria-hidden="true">&laquo;</span></a> 
 
      </li> 
 
      <li class="active"> 
 
       <a href="#">1</a> 
 
      </li> 
 
      <li> 
 
       <a href="#">2</a> 
 
      </li> 
 
      <li> 
 
       <a href="#">3</a> 
 
      </li> 
 
      <li> 
 
       <a href="#">4</a> 
 
      </li> 
 
      <li> 
 
       <a href="#">5</a> 
 
      </li> 
 
      <li> 
 
       <a aria-label="Next" href="#"><span aria-hidden="true">&raquo;</span></a> 
 
      </li> 
 
      </ul> 
 
     </nav> 
 
     </center> 
 
     <div class="col-sm-6 col-xs-12"> 
 
     <div class="well"> 
 
      <img class="center-block" src="https://cdn.sstatic.net/Sites/stackoverflow/img/[email protected]" style="border-radius: 50%;" height="80" width="80"> 
 
      <h3 style="text-align: center;">Card</h3> 
 
      <p>This is Text. This is Text. This is Text. </p> 
 
      <a href="#" class="btn btn-purple btn-sm"><i class="fa fa-sign-in" aria-hidden="true"></i> Button!</a> 
 
      <a href="#" class="btn btn-info btn-sm"><i class="fa fa-info-circle" aria-hidden="true"></i> Button!</a> 
 
     </div> 
 
     </div> 
 
     <div class="col-sm-6 col-xs-12"> 
 
     <div class="well"> 
 
      <img class="center-block" src="https://cdn.sstatic.net/Sites/stackoverflow/img/[email protected]" style="border-radius: 50%;" height="80" width="80"> 
 
      <h3 style="text-align: center;">Card</h3> 
 
      <p>This is Text. This is Text. This is Text. This is Text. This is Text. This is Text. This is Text. </p> 
 
      <a href="#" class="btn btn-purple btn-sm"><i class="fa fa-sign-in" aria-hidden="true"></i> Button!</a> 
 
      <a href="#" class="btn btn-info btn-sm"><i class="fa fa-info-circle" aria-hidden="true"></i> Button!</a> 
 
     </div> 
 
     </div> 
 
     <div class="col-sm-6 col-xs-12"> 
 
     <div class="well turbo"> 
 
      <img class="center-block" src="https://cdn.sstatic.net/Sites/stackoverflow/img/[email protected]" style="border-radius: 50%;" height="80" width="80"> 
 
      <h3 style="text-align: center;">Card</h3> 
 
      <p>This is Text. This is Text. This is Text. </p> 
 
      <a href="#" class="btn btn-purple btn-sm"><i class="fa fa-sign-in" aria-hidden="true"></i> Button!</a> 
 
      <a href="#" class="btn btn-info btn-sm"><i class="fa fa-info-circle" aria-hidden="true"></i> Button!</a> 
 
     </div> 
 
     </div> 
 
     <div class="col-sm-6 col-xs-12"> 
 
     <div class="well"> 
 
      <img class="center-block" src="https://cdn.sstatic.net/Sites/stackoverflow/img/[email protected]" style="border-radius: 50%;" height="80" width="80"> 
 
      <h3 style="text-align: center;">Card</h3> 
 
      <p>This is Text. This is Text. This is Text. </p> 
 
      <a href="#" class="btn btn-purple btn-sm" style="vertical-align: bottom;"><i class="fa fa-sign-in" aria-hidden="true"></i> Button!</a> 
 
      <a href="#" class="btn btn-info btn-sm"><i class="fa fa-info-circle" aria-hidden="true"></i> Button!</a> 
 
     </div> 
 
     </div> 
 
     <div class="col-sm-6 col-xs-12"> 
 
     <div class="well"> 
 
      <img class="center-block" src="https://cdn.sstatic.net/Sites/stackoverflow/img/[email protected]" style="border-radius: 50%;" height="80" width="80"> 
 
      <h3 style="text-align: center;">Card</h3> 
 
      <p>This is Text. This is Text. This is Text. This is Text. </p> 
 
      <a href="#" class="btn btn-purple btn-sm"><i class="fa fa-sign-in" aria-hidden="true"></i> Button!</a> 
 
      <a href="#" class="btn btn-info btn-sm"><i class="fa fa-info-circle" aria-hidden="true"></i> Button</a> 
 
     </div> 
 
     </div> 
 
     <div class="col-sm-6 col-xs-12"> 
 
     <div class="well"> 
 
      <img class="center-block" src="https://cdn.sstatic.net/Sites/stackoverflow/img/[email protected]" style="border-radius: 50%;" height="80" width="80"> 
 
      <h3 style="text-align: center;">Card</h3> 
 
      <p>This is Text. This is Text. This is Text. This is Text. </p> 
 
      <a href="#" class="btn btn-purple btn-sm"><i class="fa fa-sign-in" aria-hidden="true"></i> Button!</a> 
 
      <a href="#" class="btn btn-info btn-sm"><i class="fa fa-info-circle" aria-hidden="true"></i> Button!</a> 
 
     </div> 
 
     </div> 
 
    </div> 
 
    </div> 
 
</div>

真ん中のコンテンツを下に沈んでしまう余分な縦方向のスペースを追加します私はフレックスボックスを使って試してみましたが、そこには井戸を入れました。私はズームインして反応しなくなり、他のコンテンツと重なっていることに気付きました。

不要な空白を追加せずに応答性を維持することなく、ページの左右にウェルを追加する最も効率的な方法は何ですか?

+0

あなたが特にあなたのコンテンツの垂直方向の '流れ' を維持する必要がありますか?外側にある3つのボックスのように、互いに関連づけられていますか?そうでない場合は、ボックスを水平視点から考え、単純に4つの列を使用することができます。実際には、カードをグループ化しなければならない場合でも、DIVの「位置」を変更してカードを「挿入」することができます。 –

+0

@ObsidianAgeなぜ私はj​​avascriptがこれで最初に選択されたタグなのか分かりません。私は本当に唯一のCSSソリューションが欲しかったので、私はまずCSSを入力しましたが、私は必要に応じてJSを使用します。はい、彼らは垂直にする必要があります。 https://discordlist.me/を見てください。これは私が複製しようとしているスタイルです。 – Zezima

+0

私はこれをやろうとしました。https://embed.plnkr.co/v5tGdurseZWmjTm8mJM7/。 –

答えて

0

あなたは同じ使用col-xx-offset-xxブートストラップのクラス

を取得するために、以下の例を試すことができますが、私はあなたが container-fluidの代わりに使用することができます container実施例に

を掲載しました。

.box { 
 
    border: 1px solid; 
 
    width: 100%; 
 
    height: 100px; 
 
    margin: 0px 0px 10px 0px; 
 
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" type="text/css" rel="stylesheet"> 
 
<div class="container"> 
 
    <div class="row"> 
 
    <div class="col-lg-2 col-md-2"> 
 
     <div class="box"> 
 
     </div> 
 
    </div> 
 
    <div class="col-lg-4 col-lg-offset-2 col-md-4 col-md-offset-2"> 
 
     <div class="box"> 
 
     </div> 
 
    </div> 
 
    <div class="col-lg-2 col-lg-offset-2 col-md-2 col-md-offset-2"> 
 
     <div class="box"> 
 
     </div> 
 
    </div> 
 
    </div> 
 
    <div class="row"> 
 
    <div class="col-lg-2 col-md-2"> 
 
     <div class="box"> 
 
     </div> 
 
    </div> 
 
    <div class="col-lg-4 col-lg-offset-2 col-md-4 col-md-offset-2"> 
 
     <div class="box"> 
 
     </div> 
 
    </div> 
 
    <div class="col-lg-2 col-lg-offset-2 col-md-2 col-md-offset-2"> 
 
     <div class="box"> 
 
     </div> 
 
    </div> 
 
    </div> 
 
</div>

ワーキングcodepen - codepen

+0

答えを編集してこれを質問の井戸に適用できますか?特別なカードは、ページの各辺の最後(左と右)にある必要がありますが、これらのボックスはページの中央部分に配置されています。私はあなたの答えを使って井戸を使って作業を試みましたが、それはちょうどそれらを壊し、それはすべて離れていました。次のものを見てください:https://embed.plnkr.co/v5tGdurseZWmjTm8mJM7/それらがすべて同じ幅と高さである必要があることを除いて、私が欲しいものを参照してください。特別なカードには少しのスペースが必要で、中央の通常のカードには近づけないでください。 – Zezima

+0

私はボックスdivを使いましたので、必要があればボックスdivといくつかのCSS stuffに 'wells'を入れてみましょう。 – LKG

0

私は一定の大きさでそれを行うにはどのようにさっぱりだが、CSSは難しいです。

body { 
 
    padding-top: 20px; 
 
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" /> 
 
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" /> 
 

 
<div class="container-fluid"> 
 

 
    <div class="row"> 
 
    <div class="col-sm-12"> 
 
     <div class="well">header row</div> 
 
    </div> 
 
    </div> 
 

 
    <div class="row"> 
 
    <div class="col-lg-3"> 
 
     <div class="well">x-well</div> 
 
     <div class="well">x-well</div> 
 
     <div class="well">x-well</div> 
 
     <div class="well">x-well</div> 
 
    </div> 
 
    <div class="col-lg-6"> 
 
     <div class="well"> 
 
     sample text 
 
     </div> 
 
     <div class="row"> 
 
     <div class="col-sm-6"> 
 
      <div class="well">x-well</div> 
 
      <div class="well">x-well</div> 
 
      <div class="well">x-well</div> 
 
      <div class="well">x-well</div> 
 
     </div> 
 
     <div class="col-sm-6"> 
 
      <div class="well">x-well</div> 
 
      <div class="well">x-well</div> 
 
      <div class="well">x-well</div> 
 
      <div class="well">x-well</div> 
 
     </div> 
 
     </div> 
 
    </div> 
 
    <div class="col-lg-3"> 
 
     <div class="well">x-well</div> 
 
     <div class="well">x-well</div> 
 
     <div class="well">x-well</div> 
 
     <div class="well">x-well</div> 
 
    </div> 
 
    </div> 
 
</div>

関連する問題