2014-10-30 6 views
0

아래 가운데에 아래의 텍스트가 포함 된 div를 가운데에 배치하고 싶을 수 있습니다. 그래도 난 내가 부트 스트랩에서 '중앙 블록'클래스를 사용 할 수있을 것입니다하지만 작동하지 않습니다부트 스트랩 - 내부에 텍스트가있는 div를 가운데에 배치하는 방법?

라이브 미리보기 : http://codepen.io/anon/pen/tCIlG

Code below: 

<div class="row"> 
     <div class="col-md-4 center-block text-center"> 

     I want to center the div that this text is in.I want to center the div that this text is in.I want to center the div that this text is in.I want to center the div that this text is in.I want to center the div that this text is in.I want to center the div that this text is in.I want to center the div that this text is in.I want to center the div that this text is in.I want to center the div that this text is in.I want to center the div that this text is in. 

     </div> 
    </div> 
+0

가능한 중복 이동 [div에서 div를 가로로 중앙에 배치하는 방법] (http://stackoverflow.com/questions/114543/how-to-horizontally-center-a-div-in-a-div) – Sasa

답변

2

.col-md-4 클래스가 떠 일으키는 센터 대신에 왼쪽. 해당 클래스에서 폭을 유지하려면, 당신은 CSS에서 그것을 대체 할 수 있습니다 :

.col-md-4.center-block { 
    float: none; 
} 

업데이트 codepen을 여기 http://codepen.io/sdsanders/pen/lHrvu

+0

고맙습니다. 쉽습니다. 열 방법을 사용하여 최선을 다하고 있습니다. 또는 별도의 CSS 등을 추가하지 않아도되는 더 좋은 방법이 있습니까? – ifusion

+1

@ifusion 위의 Matt의 대답은 CSS 작성을 요구하지 않는 또 다른 옵션입니다. –

+0

당신은 아마도 부트 스트랩 그리드를 해킹하는 것을 피하기를 원할 것입니다. 바로 아래와 같이 오프셋합니다. –

2

당신이

<div class="row"> 
 
     <div class="col-md-4 col-md-offset-4"> 
 

 
     I want to center the div that this text is in.I want to center the div that this text is in.I want to center the div that this text is in.I want to center the div that this text is in.I want to center the div that this text is in.I want to center the div that this text is in.I want to center the div that this text is in.I want to center the div that this text is in.I want to center the div that this text is in.I want to center the div that this text is in. 
 

 
     </div> 
 
    </div>

+0

굉장하고, 감사합니다. Matt! – ifusion

+0

@ifusion no prob, 받아 들인 질문으로 표시해주세요. –

관련 문제