私は最初からウェブサイトを作っています。私はw3schoolのグリッドビューを見て、それを使うことを考えました。とにかく、私は.whole要素に残っているfloatを使用しましたが、動作しません。私はすでに左にクリアするためにそれを変更しようとしましたが、それも動作していません。誰かが2つの.sections要素を隣り合わせに配置するのを助けることができますか?2つのグリッドビューを互いに近くに配置するにはどうすればよいですか?
* {
box-sizing: border-box;
}
.row::after {
content: "";
clear: both;
display: table;
}
[class*="col-"] {
float: left;
padding: 15px;
}
body {
font-family: "Lucida Sans", sans-serif;
}
.header {
width: 500px;
background-color: #9933cc;
color: #ffffff;
padding: 15px;
}
.menu ul {
list-style-type: none;
margin: 0;
padding: 0;
}
.menu li {
padding: 8px;
margin-bottom: 7px;
background-color: #33b5e5;
color: #ffffff;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
}
.menu li:hover {
background-color: #0099cc;
}
@media only screen and (min-width: 600px) {
/* For desktop: */
.col-3 {
width: 15%;
}
.col-6 {
width: 20%;
}
}
.sections {
width: 1300px;
}
.whole {
float: left;
}
<div class="whole">
<div class="sections">
<div class="header">
<h1>Chania</h1>
</div>
<div class="row">
<div class="col-3 menu">
<ul>
<li>The Flight</li>
<li>The City</li>
<li>The Island</li>
<li>The Food</li>
</ul>
</div>
<div class="col-6">
<h1>The City</h1>
<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>
</div>
</div>
</div>
<div class="sections">
<div class="header">
<h1>Chania</h1>
</div>
<div class="row">
<div class="col-3 menu">
<ul>
<li>The Flight</li>
<li>The City</li>
<li>The Island</li>
<li>The Food</li>
</ul>
</div>
<div class="col-6">
<h1>The City</h1>
<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>
</div>
</div>
</div>
</div>
、これは間違いなくので、このような類似した質問をチェックアウトhttps://stackoverflow.com/questions/18344904/how-to-align-two-前に投稿されましたdivs-side-by-side-float-clear-and-overflow-elements – SMT
[フロート、クリア、およびオーバーフロー要素を固定した位置で2つのdivを並べる方法div /] (https://stackoverflow.com/questions/18344904/how-to-align-two-divs-side-by-side-using-the-float-clear-and-overflow-elements) –