2017-10-17 15 views
-1

各区画(スペース)を区切りたいと思います。 私はあるマージンを与えれば、1つのdivは次の行に移動します。どうやって同じ行に3つのボックスにスペースを入れることができますか? CSSで何を書く必要がありますか?各部門をどのように分けることができますか?

は、私は基本的なHTML structreを持っている:

<div class="col-lg-4 col-md-6"> <section class="a"> A Title </section> <p>Lorem ipsum dolor sit amet,</p></div> 
<div class="col-lg-4 col-md-6"> <section class="b"> B Title </section> <p>Lorem ipsum dolor sit amet,</p></div> 
<div class="col-lg-4 col-md-12"> <section class="C"> C </section> <p>Lorem ipsum dolor sit amet,</p></div> 

LG-4:33.33パーセント
MD-6:50%あなたは最大12可能性があり、 "COL" 内の予約スペースを追加する必要があります

+0

はあなたのコードを共有するにも –

+0

おそらく、あなたに切り替える必要がありますこのグリッドよりも柔軟性のある何かをフレックスボックスに試してみてください。 https://css-tricks.com/snippets/css/a-guide-to-flexbox/ – sjahan

+0

パディングを適用してみてください。 – Sagar

答えて

1

Foは:1「行」あなたは「COL-LG-4」は余白に十分なスペースではありません使用している場合ので、あなたはdivのコンテナに「余白」を設定し、このように、内部でより多くのdivを追加する必要がでうまくいけば、余分なCSSを書く必要はありません。最も簡単な方法はブートストラップと一緒に行くことです。このpenはそれを実証しています。

ブートストラップクラスの後、ちょうどcol-lg-4の内側にあなたが持っている直接の子供のためのコンテナを追加し、パディングやマージンを使用し、それは常に私がインラインブロックを使用しないでくださいcol-lg-4

<div class="row"> 
    <div class="col-lg-4 col-md-4"> 
    <div class="section"> 
     <section class="a"> A Title </section> <p>Lorem ipsum dolor sit amet,</p> 
    </div> 
    </div> 
    <div class="col-lg-4 col-md-4"> 
    <div class="section"> 
     <section class="b"> B Title </section> <p>Lorem ipsum dolor sit amet,</p> 
    </div> 
    </div> 
    <div class="col-lg-4 col-md-4"> 
    <div class="section"> 
     <section class="C"> C </section> <p>Lorem ipsum dolor sit amet,</p> 
    </div> 
    </div> 
</div> 
0

<div class="col-lg-4" style="padding-left: 5px"> 
    <div calss="box col-lg-12"> 
     <!-- Data with padding --> 
    </div> 
</div> 
0

の内側になります。私はこの形状に必要があります。ここでは

<!DOCTYPE html> 
<html> 
<head> 
    <meta charset="utf-8"> 
    <title>Example - 1</title> 
    <link rel="stylesheet" href="css/style.css"> 
</head> 
<body> 
    <h1> Our Menu </h1> 

<div class="col-lg-4 col-md-6"> <section class="a"> A title</section> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </p></div> 
<div class="col-lg-4 col-md-6"> <section class="b"> B Title </section> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p></div> 
<div class="col-lg-4 col-md-12"> <section class="c"> C Title </section> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </p></div> 

</body> 
</html> 

私のCSSファイルされる:ここで

は私のHMTLコードです

*{ 
    font-family: Comic Sans MS, cursive, sans-serif; 
    box-sizing: border-box; 

} 

h1 { 
    text-align: center; 
} 

div{ 

    background-color: gray; 
    float: left; 

} 
p{ 

    padding: 5px; 
    float: left;  

} 

section{ 
    width: 110px; 
    border: solid 1px black; 
    text-align: center; 
    font-weight: bold; 
    float: right; 

} 

.a{ 
    background-color:#D59898; 
} 

.b{ 
    background-color:#C14543; 
    color: white; 
} 

.c{ 
    background-color:#E5D198; 
} 

@media (min-width: 992px) { 
    .col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12 { 
    float: left; 
    border: 2px solid black; 
    } 
    .col-lg-1 { 

    width: 8.33%; 
    } 
    .col-lg-2 { 
    width: 16.66%; 
    } 
    .col-lg-3 { 
    width: 25%; 
    } 
    .col-lg-4 { 
    width: 33.33%; 
    } 
    .col-lg-5 { 
    width: 41.66%; 
    } 
    .col-lg-6 { 
    width: 50%; 
    } 
    .col-lg-7 { 
    width: 58.33%; 
    } 
    .col-lg-8 { 
    width: 66.66%; 
    } 
    .col-lg-9 { 
    width: 74.99%; 
    } 
    .col-lg-10 { 
    width: 83.33%; 
    } 
    .col-lg-11 { 
    width: 91.66%; 
    } 
    .col-lg-12 { 
    width: 100%; 
    } 
} 
/********** Tablet devices only **********/ 
@media (min-width: 768px) and (max-width: 991px) { 
    .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12 { 
    float: left; 
    border: 2px solid black; 
    } 
    .col-md-1 { 
    width: 8.33%; 
    } 
    .col-md-2 { 
    width: 16.66%; 
    } 
    .col-md-3 { 
    width: 25%; 
    } 
    .col-md-4 { 
    width: 33.33%; 
    } 
    .col-md-5 { 
    width: 41.66%; 
    } 
    .col-md-6 { 
    width: 50%; 
    } 
    .col-md-7 { 
    width: 58.33%; 
    } 
    .col-md-8 { 
    width: 66.66%; 
    } 
    .col-md-9 { 
    width: 74.99%; 
    } 
    .col-md-10 { 
    width: 83.33%; 
    } 
    .col-md-11 { 
    width: 91.66%; 
    } 
    .col-md-12 { 
    width: 100%; 
    } 
} 
関連する問題