この内容は古いバージョンです。最新バージョンを表示するには、戻るボタンを押してください。
バージョン:2
ページ更新者:ぼうず
更新日時:2026-06-11 05:25:33

タイトル: Bootstrapで両サイドを固定して広告を表示させる方法
SEOタイトル: 【CSS】 Bootstrapで両サイドを固定して広告を表示させる方法

この本文には実行可能なタグ等が含まれるため、安全のためHTMLソースとして表示しています。本文データは変更していません。

<table border="1" cellpadding="1" cellspacing="1" style="width:750px">
	<tbody>
		<tr>
			<td style="background-color:#000000">
			<p><span style="color:#ffffff">&nbsp; <div class="row"><br />
			&nbsp; &nbsp; <!-- 左サイドの広告 --><br />
			&nbsp; &nbsp; <div class="col-lg-2 col-md-3 d-none d-md-block"><br />
			&nbsp; &nbsp; &nbsp; <div class="ad-left"><br />
			&nbsp; &nbsp; &nbsp; &nbsp; <!-- ここに左側の広告コードを追加 --><br />
			&nbsp; &nbsp; &nbsp; </div><br />
			&nbsp; &nbsp; </div></span></p>

			<p><span style="color:#ffffff">&nbsp; &nbsp; <!-- メインコンテンツ --><br />
			&nbsp; &nbsp; <div class="col-lg-8 col-md-6"><br />
			&nbsp; &nbsp; &nbsp; <div class="main-content"><br />
			&nbsp; &nbsp; &nbsp; &nbsp; <!-- ここにWebサイトのメインコンテンツを追加 --><br />
			&nbsp; &nbsp; &nbsp; </div><br />
			&nbsp; &nbsp; </div></span></p>

			<p><span style="color:#ffffff">&nbsp; &nbsp; <!-- 右サイドの広告 --><br />
			&nbsp; &nbsp; <div class="col-lg-2 col-md-3 d-none d-md-block"><br />
			&nbsp; &nbsp; &nbsp; <div class="ad-right"><br />
			&nbsp; &nbsp; &nbsp; &nbsp; <!-- ここに右側の広告コードを追加 --><br />
			&nbsp; &nbsp; &nbsp; </div><br />
			&nbsp; &nbsp; </div><br />
			&nbsp; </div><br />
			</div></span></p>

			<p>&nbsp;</p>

			<p><span style="color:#ffffff"><style><br />
			&nbsp; .ad-left, .ad-right {<br />
			&nbsp; &nbsp; position: fixed; /* 広告を固定する */<br />
			&nbsp; &nbsp; padding-top: 10px;<br />
			&nbsp; &nbsp; padding-bottom: 10px;<br />
			&nbsp; &nbsp; top: 50%; /* 画面の縦方向の真ん中に広告を配置 */<br />
			&nbsp; &nbsp; transform: translateY(-50%); /* 広告自体の縦方向の真ん中を基準にする */<br />
			&nbsp; }</span></p>

			<p><span style="color:#ffffff">&nbsp; .ad-left {<br />
			&nbsp; &nbsp; left: 0; /* 画面の左側に広告を配置 */<br />
			&nbsp; }</span></p>

			<p><span style="color:#ffffff">&nbsp; .ad-right {<br />
			&nbsp; &nbsp; right: 0; /* 画面の右側に広告を配置 */<br />
			&nbsp; }</span></p>

			<p><span style="color:#ffffff">&nbsp; .main-content {<br />
			&nbsp; &nbsp; padding: 20px;<br />
			&nbsp; }<br />
			</style></span></p>
			</td>
		</tr>
	</tbody>
</table>