# 兩欄式

操作範例

![](/files/-MKNNi1s8aFFR0J_CY8U)

### 範例一、使用clear:both

{% tabs %}
{% tab title="css" %}

```css

.wrap { background-color: pink; width: 500px;
 margin-left: auto; margin-right: auto; }
.clearFix { display: block; clear: both; }
.navi, .main { float: left; }
.navi { 
   background-color: yellowgreen;
   width: 100px;
 }
.main { 
     background-color: gray; 
     width: 400px;
 }
```

{% endtab %}

{% tab title="html" %}

```markup
<body>
	<div class="wrap">
		<div class="navi">
			<p>左邊</p>
			<p>左邊</p>
			<p>左邊</p>
		</div>
		<div class="main">
			<p>右邊</p>
			<p>右邊</p>
			<p>右邊</p>
			<p>右邊</p>
			<p>右邊</p>
			<p>右邊</p>
			<p>右邊</p>
		</div>
		<span class="clearFix"></span>
	</div>
</body>
```

{% endtab %}
{% endtabs %}

### 範例二、margin

```css
@charset "utf-8";

.wrap {
	background-color: pink;
	width: 500px;
	margin-left: auto;
	margin-right: auto;
}

.navi {
	float: left;
	width: 100px;
	background-color: yellowgreen;
}

.main {
	margin-left: 100px;
	background-color: gray;
}

```

### 範例三、float

```css
@charset "utf-8";

.wrap {
	background-color: pink;
	width: 500px;
	margin-left: auto;
	margin-right: auto;
	overflow: hidden;
}

.navi, .main {
	float: left;
}

.navi {
	background-color: yellowgreen;
	width: 100px;
}

.main {
	background-color: gray;
	width: 400px;
}

```

### 範例四、 after、 before

```css
@charset "utf-8";

.wrap {
	background-color: pink;
	width: 500px;
	margin-left: auto;
	margin-right: auto;
}

.wrap::after {
	content: "";
	display: block;
	clear: both;
}

.navi, .main {
	float: left;
}

.navi {
	background-color: yellowgreen;
	width: 100px;
}

.main {
	background-color: gray;
	width: 400px;
}

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://information9527.gitbook.io/html/qian-duan-san-xiong-di/css-ji-ben-shi-yong/css-pai-ban/liang-lan-shi-float.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
