私はテストしている簡単なグリッドを持っています。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>
(他のいくつかのHTMLのトリックやCSSの方法と同様に、Thieliciousの答えのように、HTMLコメントの方法を含む)a run down of different ways to get around thisを与えますスペースを取ることができるそれらの周りの空白文字。彼らはおそらくレンダリングし、あなたの要素を周りに押しています –
'.col-9'と' .col-3'の間のスペースを削除します。 https://css-tricks.com/fighting-the-space-between-inline-block-elements/ – mrfour