2017-10-17 14 views
-1

각 div를 (공백으로) 구분하고 싶습니다. 약간의 여백을 주면 한 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

이 아마도 당신이 전환해야 공유 이 격자보다 더 유연하고 flexboxes를 시도해보십시오. https://css-tricks.com/snippets/css/a-guide-to-flexbox/ – sjahan

+0

패딩을 적용 해보십시오. – Sagar

답변

1

FO을 : 그래서 만약 당신이 "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%; 
    } 
}