gpt4 book ai didi

html - 我是否必须添加一个额外的 div 才能实现此目的?

转载 作者:太空宇宙 更新时间:2023-11-04 15:35:46 24 4
gpt4 key购买 nike

我想知道,如果我想让页眉的紫色和页脚的蓝色在整个页面上延伸 100%,但让中间的内容与中间的橙色对齐,我应该怎么做实现了吗?

我是否必须在页眉和页脚周围添加额外的 100% div 并在其中着色?这似乎是一种废话。

这是我正在使用的代码: http://jsfiddle.net/HMsKa/21/

HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en-US">
<head>
<title>Title</title>
<link href="/static/css/main.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="container">
<div id="header" class="thin_width" >

<a href="/"><img src="/static/img/header.jpg" id="logo" alt="coming soon" title="coming soon"></a>
<ul>
<li><a href="/posts/list/">Link1</a></li>
<li><a href="/posts/create/">Link 2</a></li>
<li><a href="/about">Link 3</a></li>
</ul>
</div>
<div id="content" class="thin_width">
<h1>Sed ut perspiciatis unde</h1>
<form id="searchForm" action="/search">
<input type="text" name="kw" class="field r2 lft dc1 tc5 b1 ts3" id="field_regular" placeholder="Keyword">
<input type="text" name="loc" class="field r2 lft dc1 tc5 b1 ts3" id="field_regular" placeholder="Location">
<input type="submit" class="button r2 b1 ts3" id="button_search" value="Search">
</form>
<p>Sed ut perspiciatne voluptatem sequi nesciunt.</p>
<p>Sed ut perspiciatne voluptatem sequi nesciunt.</p>
<p>Sed ut perspiciatne voluptatem sequi nesciunt.</p>
<p>Sed ut perspiciatne voluptatem sequi nesciunt.</p>
<p>Sed ut perspiciatne voluptatem sequi nesciunt.</p>
<p>Sed ut perspiciatne voluptatem sequi nesciunt.</p>
<p>Sed ut perspiciatne voluptatem sequi nesciunt.</p>
<p>Sed ut perspiciatne voluptatem sequi nesciunt.</p>
<p>Sed ut perspiciatne voluptatem sequi nesciunt.</p>
<p>Sed ut perspiciatne voluptatem sequi nesciunt.</p>
<p>Sed ut perspiciatne voluptatem sequi nesciunt.</p>
<p>Sed ut perspiciatne voluptatem sequi nesciunt.</p>
<p>Sed ut perspiciatne voluptatem sequi nesciunt.</p>
<p>Sed ut perspiciatne voluptatem sequi nesciunt.</p>
<p>Sed ut perspiciatne voluptatem sequi nesciunt.</p>
<p>Sed ut perspiciatne voluptatem sequi nesciunt.</p>
<p>Sed ut perspiciatne voluptatem sequi nesciunt.</p>
<p>Sed ut perspiciatne voluptatem sequi nesciunt.</p>
<p>Sed ut perspiciatne voluptatem sequi nesciunt.</p>
</div>
<div id="footer" class="thin_width">
&#169; 2012 Company, Inc.
<ul>
<li><a href="/contact">Contact</a></li>
<li><a href="/faq">FAQ</a></li>
<li><a href="/terms">Terms</a></li>
<li><a href="/privacy">Privacy</a></li>
</ul>
</div>
</div>
</body>
</html>

CSS

/* GENERAL */
html { height:100%; }
body { height:100%; font-family: Arial, Helvetica, sans-serif; font-weight:normal; font-style:normal; font-size:100%; }
p { font size: 13px; margin: 10px 0; padding: 0; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; }
blockquote { font-style: italic; }

.thin_width { width: 600px; }

#container { min-height: 100%; position: relative; background-color: red;
width: 600px;
margin: 0 auto;
}
#content {padding-bottom: 80px; background-color: orange;}
#footer {
position:absolute;
bottom: 0;
clear: both;
float:left;
height:60px;
background-color: blue;
}

#footer li { display:inline; }

#header {background-color: purple;}

最佳答案

你可以这样做:My Fiddle

怎么做:

只需从包装器 div 中取出页眉和页脚,并为页眉和页脚提供 100% 的宽度。

要使页眉和页脚的内容居中,您需要将页眉和页脚中的内容包装在包装器 div 中,为其指定 width 600px; 并使用 margin: auto; 将其引入页面流

关于html - 我是否必须添加一个额外的 div 才能实现此目的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12822255/

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