私は非常に単純な html ページを作成しており、自分のページで次の 2 つのことを行う方法を知りたいです。
- コンテナ div があり、コンテナ div をページの中央に配置したいと考えています。
- ウィンドウのサイズを変更すると、コンテナ div が拡大および縮小します。
添付のコードを書きましたが、コンテナは常に左側にくっついており、ウィンドウのサイズを変更してもサイズが変わりません。
<title>Demo</title>
<head>This is a demo</head>
<style>
#nav
{
background-color: red;
float: left;
width: 200px;
position:relative;
}
#detail
{
background-color: green;
float : right;
width: 800px;
position:relative;
}
div.testDetail
{
margin-top:10px;
margin-left:20px;
margin-right:20px;
margin-bottom:10px;
}
#container
{
width:1000px;
position:relative;
}
</style>
<hr>
<body>
<div id="container">
<div id="nav">
<ul>Tests</ul>
</div>
<div id="detail">
<div class="testDetail">
<image style="float:right;margin:5px;" src="test1.jpg" width="50px" height="50px"/>
<image style="float:right;margin:5px;" src="test2.jpg" width="50px" height="50px"/>
<image style="float:right;margin:5px;" src="test3.jpg" width="50px" height="50px"/>
<image style="float:right;margin:5px;" src="test4.jpg" width="50px" height="50px"/>
<h3>Title</h3>
<p>Testing</p>
</div>
<hr>
</div>
</div>
<body>
ここで何か見逃しましたか?どんな助けでも感謝します!
ありがとう。