ウェブ学のすすめ

Study of Web Design & Programing

floatを使ったレイアウト

解答

floatを使ったレイアウト - jsdo.it - share JavaScript, HTML5 and CSS

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<title>floatを使ったレイアウト</title>
<style type="text/css">
* {
  margin: 0;
  padding: 0;
}

body {
  color: #fff;
  background-color: #ccc;
}

#container {
  background-color: #fff;
  width: 800px;
  height: auto;
  margin: 0 auto;
  padding: 10px;
}

#header {
  background-color: #a3bed5;
  height: 100px;
  margin: 0 0 10px;
}

#wrapper {
  width: 800px;
  height: auto;
  overflow: auto;
}

#content {
  background-color: #dcd78a;
  width: 570px;
  height: 310px;
  float: right;
  margin: 0 0 10px;
}

h1,h2 {
  padding: 10px;
}

p {
  padding: 10px;
  font-weight: bold;
}

#sidebar {
  background-color: #9cc56e;
  width: 220px;
  height: auto;
}

ul {
  padding: 0 0 10px;
}

li {
  width: 200px;
  height: 80px;
  padding: 10px 10px 0;
}

#footer {
  clear: both;
  background-color: #e0b9d2;
  height: 50px;
} 

address {
  text-align: center;
  font-style: normal;
  font-weight: bold;
  padding: 15px 0;
}
</style>
</head>
<body>
<div id="container">
<div id="header">
<h1>ここにサイトタイトルが入る</h1>
</div>
<div id="wrapper">
<div id="content">
<h2>ここに見出しが入る</h2>
<p>ここに本文が入る</p>
</div>
<div id="sidebar">
<ul>
<li><a href="#"><img src="http://jsrun.it/assets/j/p/x/6/jpx6R.gif" alt="バナー" width="200px" height="80px" /></a></li>
<li><a href="#"><img src="http://jsrun.it/assets/j/p/x/6/jpx6R.gif" alt="バナー" width="200px" height="80px" /></a></li>
<li><a href="#"><img src="http://jsrun.it/assets/j/p/x/6/jpx6R.gif" alt="バナー" width="200px" height="80px" /></a></li>
</ul>
</div>
</div>
<div id="footer">
<address>ここに連絡先のテキストが入る</address>
</div>
</div>
</body>
</html>

Valid XHTML 1.0 Transitional 正当なCSSです!