2013-02-10 3 views

답변

2

HTML :

<div class="float"></div> 
<div class="float"></div> 
<div class="float"></div> 

CSS :

.float { 
    width:33.33%; 
    height:400px; 
    float:left; 
} 

OR :

.float { 
    width:33.33%; 
    height:400px; 
    display:inline-block; 
} 

Demonstration

float 또는 display 속성을 사용하여 가로로 정렬 할 수 있습니다.

+1

'float' 또는'디스플레이 : 인라인 block'. 둘 다 사용할 필요는 없습니다. –

+0

@RainDiao 코멘트 주셔서 감사합니다! 그래, 알아. 승인. 나는 그것을 바꾼다. –

+0

@RainDiao 그렇게 할 때 모든 컨테이너를 결합합니다. 폭이 30px이고 높이가 자동으로 만 필요합니다. 그렇게하면 모든 용기가 오른쪽으로 압착됩니다. 플로팅과 디스플레이입니다. – Zevoxa

0
<div class="container"> 
    <div class="float"></div> 
    <div class="float"></div> 
    <div class="float"></div> 
</div> 

#container { 
    text-align: center; 
} 

.float { 
    display:inline-block; 
    text-align: left; 

    width:100px; 
    height:400px;   
    background:green; 
    margin:5px; 
} 

데모 : http://jsfiddle.net/ts9BB/3/

관련 문제