gpt4 book ai didi

css - 布局问题 : Fixed size sidebar w/fluid content & clear

转载 作者:行者123 更新时间:2023-11-28 13:52:05 24 4
gpt4 key购买 nike

我需要一个用于固定大小侧边栏和流动内容区域的 CSS 布局。问题是,这种格式的大多数 css 布局都使用 float 来定位侧边栏。因此,我不能在内容区域中使用 clear:both。

查看附加的 html。内容区域在 float 时跳到导航内容的底部。

我需要一个针对这种类型的 css 布局的解决方案,它仍然允许我在内容区域内使用 floats/clear。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<style type="text/css" media="screen">
body {
margin: 0;
padding: 0;
}

#nav {
float: left;
width: 160px;
}

#content {
margin: 0 0 0 200px;
background-color: green;
}
</style>
</head>
<body>
<div>

<div id="nav">

This is the nav content<br/>
This is the nav content<br/>
This is the nav content<br/>
This is the nav content<br/>
This is the nav content<br/>
This is the nav content<br/>
This is the nav content<br/>
This is the nav content<br/>
This is the nav content<br/>
This is the nav content<br/>
This is the nav content<br/>
This is the nav content<br/>
This is the nav content<br/>
This is the nav content<br/>
This is the nav content<br/>

</div>
<div id="content">

This is the main content<br/>
This is the main content<br/>
This is the main content<br/>
This is the main content<br/>


<div style="padding: 10px; float: left; width: 100px; background-color: yellow;">Left</div>
<div style="padding: 10px; float: right; width: 100px; background-color: orange;">Right</div>

<div style="clear: both;"> </div>

(This shouldn't be way down here) This is the main content<br/>
This is the main content<br/>
This is the main content<br/>
This is the main content<br/>

</div>
</div>
</body>
</html>

最佳答案

我将#nav 从“float:left;”更改为到“position:absolute;”。这会如您所愿吗?

关于css - 布局问题 : Fixed size sidebar w/fluid content & clear,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1196876/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com