我正在制作一个非常简单的html页面,并且想知道如何为我的页面执行以下两项操作:
我写了附加的代码,但容器总是粘在左边,当我调整窗口大小时它不会改变大小.
<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>
Run Code Online (Sandbox Code Playgroud)
我在这里错过了什么吗?任何帮助将不胜感激!
谢谢.
<div id="my-div">
...content goes here
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
#my-div{
//For center align
margin: 0 auto;
// For grow & shrink as per screen size change values as per your requirements
width: 80%;
height: 50%;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
71976 次 |
最近记录: |