2012-10-10 69 views
2

我在想这可能只是有一个包装,而不是单独的页眉和页脚。我需要所有这些包装吗?

这是可以做到的,我可以有一个单一的包装容器,在所有元素上的固定宽度的中间内容?

这里是的jsfiddle: http://jsfiddle.net/HMsKa/

下面是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-wrap"> 
      <div id="header-wrap" class="full_width"> 
       <div id="header-container" class="dc1"> 
        <div id="header" class="thin_width rel"> 
         <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> 
      </div> 

      <div id="container" class="thin_width"> 
       <div class="full_width" style="height:auto;"> 
        <div id="col-main">     
     <h1>Sed ut perspiciatis unde</h1> 
      <div id="fullwidth"> 
       <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> 
      </div> 
      <p>Sed ut perspiciatne voluptatem sequi nesciunt.</p> 
    </div> 
       </div>      
      </div> 

      <div id="footer-wrap" class="thin_width"> 
       <div id="footer-container" class="full_width abs dc1"> 
        <div id="footer" class="thin_width rel"> 
        &#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> 
      </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; } 

/*POSITIONING */ 
.lft { float: left; } 
.rgt { float: right; } 
.rel { position: relative; } 
.abs { position: absolute; } 

/* TEXT COLOURS */ 
.tc6 { color: #4C4C4C; } 
.tc5 { color: #333333; } 
.tc4 { color: #999999; } 
.tc3 { color: #808080; } 
.tc2 { color: #F5F5F5; } 
.tc1 { color: #FFFFFF; } 

/* TEXT STYLING */ 
.bold { font-weight: bold; } 
.italic { font-style:italic; } 

/* TEXT SIZES */ 
.ts5 { font-size: 21px; } 
.ts4 { font-size: 18px; } 
.ts3 { font-size: 15px; } 
.ts2 { font-size: 13px; } 
.ts1 { font-size: 11px; } 

/* DIV COLOURS */ 
.dc6 { background-color: #4C4C4C; } 
.dc5 { background-color: #333333; } 
.dc4 { background-color: #999999; } 
.dc3 { background-color: #808080; } 
.dc2 { background-color: #F5F5F5; } 
.dc1 { background-color: #FFFFFF; } 

/* WIDTHS */ 
.full_width { width: 100%; } 
.thin_width { width: 940px; } 

/* BORDERS */ 
.b1 { border: 1px solid; } 

/* RADIUS */ 
.r6 { border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px; } 
.r2 { border-radius: 2px; -moz-border-radius: 2px; -webkit-border-radius: 2px; } 

/* FIELD */ 
.field { line-height:27px; font-family:arial, sans-serif; border-color: #d9d9d9; border-top:solid 1px #c0c0c0; padding-left:5px; margin-right: 15px; width:250px; } 

/* BUTTON */ 
.button { cursor:pointer; font-family: arial, sans-serif; min-width: 70px; padding-left: 20px; padding-right: 20px; padding-top: 10px; padding-bottom: 10px; color: white; } 
.button:hover { border: 1px solid #2F5BB7; } 
.button:active { -moz-box-shadow: 0 0 2px #888; -webkit-box-shadow: 0 0 2px #888; box-shadow: 0 0 2px #888; } 

/* BUTTONS */ 
#button_search { height: 34px; background: url(http://www.divology.com/wp-content/themes/divology/tutorials/google-search/ico-search.png) no-repeat #4d90fe center; border: 1px solid #3079ED; text-indent:-999px; color: transparent; line-height:0; font-size:0; } 
#button_primary { border-color: #3079ED; background-color: #55A4F2; } 
#button_secondary { border-color: gray; } 
#field_regular { height:27px; } 

/* FIELDS */ 
#field_large { height:300px; } 

/* HEADER */ 
#header-wrap { top: 0; left: 0; } 
#header-container { line-height: 60px; height: 60px; border-bottom: 1px solid #E5E5E5; } 
#header { margin: 0 auto; position: relative; } 
#header h1 { color: #beffbf; text-align: left; width: 290px; margin: 0; position: absolute; left: 0; top: 20px; } 
#header h1 em { color: #90b874; font-size: small; display: block; } 
#header ul { top:0; margin: 0; padding: 0; list-style: none; position: absolute; right: 0; } 
#header ul li { float: left; margin-right: 5px; } 
#header ul li a{ color: #90b874; font-weight: bold; font-size: 1.4em; margin-right: 5px; text-decoration: none; } 
#header ul li a:hover { color: #beffbf; } 

/* CONTAINER */ 
#container { margin: 0 auto; font-size: 1.4em; overflow: auto; padding: 31px 0 80px 0px; } 
#container-wrap { min-height:100%; position:relative; min-width: 940px; } 
#logo { height:20px; } 

/* FOOTER */ 
#footer-wrap { bottom: 0; left: 0; } 
#footer-container { line-height: 60px; height: 60px; bottom: 0; border-top: 1px solid #E5E5E5; } 
#footer { margin: 0 auto; position: relative; } 
#footer ul { margin: 0; padding: 0; list-style: none; position: absolute; top: 0; right: 0; } 
#footer ul li { float: left; margin-right: 5px; } 
#footer ul li a { color: #90b874; font-size: 12px; padding-left: 10px; padding-right: 10px; text-decoration: none; } 
#footer ul li a:hover { color: #beffbf; } 

#faq EM { display:none; } 
#faq LI STRONG { font-weight:normal; color:#246; text-decoration:underline; cursor:pointer; } 

.hidden { display:none; } 

#content{ 
    background: orange; 
    height: auto; 
} 

#col-main { overflow:hidden; } 

任何投入,将不胜感激!谢谢。

+0

不,你真的不需要所有的div。我已经将你的html更新为最低限度。看看你是否可以自己更新CSS。如果没有,我会在这里看到,我会在你的路上帮助你。 http://jsfiddle.net/HMsKa/6/ – besluitloos

+0

非常感谢您的帮助!麻烦的是,页脚不再停靠在底部。我是否认为所有这些额外的标签都只是为了达到这个效果? –

+0

不是。因为如果你的屏幕会更高,它仍然不会停靠在底部。更多来,只要一秒 – besluitloos

回答

1

我会把它放在一个答案,所以你可以给予好评,并接受;-)

明白了。

只需一点点内容:http://jsfiddle.net/HMsKa/10

随着越来越多的内容,那么该网页是高:http://jsfiddle.net/HMsKa/12

我没有测试它彻底,所以你还是应该做到这一点。而且您可能想要使用“最小高度快速破解”(min-height piece)(dustindiaz.com/min-height-fast-hack)。

+0

谢谢你的帮助。我做了一些调整,我有这个。两个问题虽然。是不是有一个单一的宽度包装,覆盖页眉,页脚和中间内容并将其宽度设置为600px更好?目前,我们将每个设置为“thin_width”。其次,你如何集中内容?与margin有关的事情:0;但我无法弄清楚。 http://jsfiddle.net/HMsKa/18/ –

+0

我用#container做到了。你可以设置一个保证金:0自动,就像这样:http://jsfiddle.net/HMsKa/21/ – besluitloos

+0

太棒了。谢谢。 –

相关问题