나는 테스트하고있는 간단한 격자가 있습니다.CSS 표시 : 인라인 블록이 다음 줄로 떨어집니다.
속성 선택기 [class*='col-]
에서 float: left
에서 display: inline-block
으로 변경하기로 결정했습니다.
float: left
을 사용할 때 col-9
에 충분한 공간이 있고 모든 것이 올바르게 작동하는지 궁금합니다. 그러나 display: inline-block
을 사용하면 요소가 다음 줄로 떨어집니다.
* {
box-sizing: border-box;
}
.header {
\t border: 1px solid red;
\t padding: 15px;
}
.col-1 {width: 8.33%;}
.col-2 {width: 16.66%;}
.col-3 {width: 25%;}
.col-4 {width: 33.33%;}
.col-5 {width: 41.66%;}
.col-6 {width: 50%;}
.col-7 {width: 58.33%;}
.col-8 {width: 66.66%;}
.col-9 {width: 75%;}
.col-10 {width: 83.33%;}
.col-11 {width: 91.66%;}
.col-12 {width: 100%;}
[class*='col-'] {
\t display: inline-block;
\t padding-top: 15px;
\t border: 1px solid red;
}
\t <div class='header'>
\t \t <h1>China</h1>
\t </div>
\t <div class='row'>
\t \t <div class='col-3'>
\t \t \t <ul>
\t \t \t \t <li>The Flight</li>
\t \t \t \t <li>The City</li>
\t \t \t \t <li>The Island</li>
\t \t \t \t <li>The Food</li>
\t \t \t </ul>
\t \t </div>
\t \t <div class='col-9'>
\t \t \t <h1>The City</h1>
\t \t \t <p>Chania is the capital of the Chania region on the island of Crete. The city can be divided in two parts, the old town and the modern city.</p>
\t \t \t <p>Resize the browser window to see how the content respond to the resizing.</p>
\t \t </div>
\t </div>
(Thielicious의 대답과 같은 HTML 주석의 방법뿐만 아니라 다른 HTML 트릭과 CSS 방법을 포함한다) 제공하지만, 인라인 요소에 민감 공간을 차지할 수있는 주변의 공백 문자. 그들은 아마 당신의 요소를 렌더링하고 밀어 넣을 것입니다. –
'.col-9'와'.col-3' 사이의 공간을 제거하십시오. https://css-tricks.com/fighting-the-space-between-inline-block-elements/ – mrfour