サンプル プログラミング

HTMLサンプル:でDIV要素を横並びにする

更新日:

CSSのDISPLAYプロパティにTABLE、TABLE-CELLで横並びにする。table-layout:fixed;で横幅が均等になる。

サンプル

<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no">
<title>サンプル</title>
</head>
<style type="text/css">
body {margin: 0;}

.table {
	width:100%;
	display:table;
	table-layout:fixed;
}
.table_cell_1,
.table_cell_2,
.table_cell_3 {
	display:table-cell;
	height:100px;
}
.table_cell_1 {
	background-color:red;
	text-align:left;
	vertical-align:top;
}
.table_cell_2 {
	background-color:green;
	text-align:center;
	vertical-align:middle;
}
.table_cell_3 {
	background-color:blue;
	text-align:right;
	vertical-align:bottom;
}
</style>
<body>
<div class="table">
<div class="table_cell_1">
table_cell_1 table_cell_1 table_cell_1 table_cell_1 table_cell_1 table_cell_1 table_cell_1 table_cell_1
</div>
<div class="table_cell_2">
table_cell_2
</div>
<div class="table_cell_3">
table_cell_3
</div>
</div>
</body>
</html>

-サンプル, プログラミング
-,

Copyright© indite , 2025 All Rights Reserved Powered by STINGER.