如何将页眉和页脚更改为全宽

诅咒

我生成了Dreamweaver为HTML5提供的默认模板。这是http://jsfiddle.net/9XFEB/我想将页眉和页脚更改为全宽。如果我提供自动属性,则页脚消失。帮助我找出我所缺少的。

<body>

<div class="container">
  <header>
    <a href="#"><img src="" alt="Insert Logo Here" width="180" height="90" id="Insert_logo" style="background-color: #C6D580; display:block;" /></a>
  </header>
  <div class="sidebar1">
    <ul class="nav">
      <li><a href="#">Link one</a></li>
      <li><a href="#">Link two</a></li>
      <li><a href="#">Link three</a></li>
      <li><a href="#">Link four</a></li>
    </ul>
    <aside>
      <p> The above links demonstrate a basic navigational structure using an unordered list styled with CSS. Use this as a starting point and modify the properties to produce your own unique look. If you require flyout menus, create your own using a Spry menu, a menu widget from Adobe's Exchange or a variety of other javascript or CSS solutions.</p>
      <p>If you would like the navigation along the top, simply move the ul to the top of the page and recreate the styling.</p>
    </aside>
  <!-- end .sidebar1 --></div>
  <article class="content">
    <h1>Instructions</h1>
    <section>
     <h2>How to use this document</h2>
      <p>Be aware that the CSS for these layouts is heavily commented. If you do most of your work in Design view, have a peek at the code to get tips on working with the CSS for the fixed layouts. You can remove these comments before you launch your site. To learn more about the techniques used in these CSS Layouts, read this article at Adobe's Developer Center - <a href="http://www.adobe.com/go/adc_css_layouts">http://www.adobe.com/go/adc_css_layouts</a>.</p>
    </section>
    <section>
      <h2>Clearing Method</h2>
      <p>Because all the columns are floated, this layout uses a clear:both declaration in the footer rule.  This clearing technique forces the .container to understand where the columns end in order to show any borders or background colors you place on the .container. If your design requires you to remove the footer from the .container, you'll need to use a different clearing method. The most reliable will be to add a &lt;br class=&quot;clearfloat&quot; /&gt; or &lt;div  class=&quot;clearfloat&quot;&gt;&lt;/div&gt; after your final floated column (but before the .container closes). This will have the same clearing effect. </p>
    </section>
    <section>
      <h2>Logo Replacement</h2>
      <p>An image placeholder was used in this layout in the header where you'll likely want to place  a logo. It is recommended that you remove the placeholder and replace it with your own linked logo. </p>
      <p> Be aware that if you use the Property inspector to navigate to your logo image using the SRC field (instead of removing and replacing the placeholder), you should remove the inline background and display properties. These inline styles are only used to make the logo placeholder show up in browsers for demonstration purposes. </p>
      <p>To remove the inline styles, make sure your CSS Styles panel is set to Current. Select the image, and in the Properties pane of the CSS Styles panel, right click and delete the display and background properties. (Of course, you can always go directly into the code and delete the inline styles from the image or placeholder there.)</p>
    </section>
  <!-- end .content --></article>
  <aside>
    <h4>Backgrounds</h4>
    <p>By nature, the background color on any block element will only show for the length of the content. If you'd like a dividing line instead of a color, place a border on the side of the .content block (but only if it will always contain more content).</p>
  </aside>
  <footer>
    <p>This footer contains the declaration position:relative; to give Internet Explorer 6 hasLayout for the footer and cause it to clear correctly. If you're not required to support IE6, you may remove it.</p>
    <address>
      Address Content
    </address>
  </footer>
  <!-- end .container --></div>
</body>
维琪

您可以简单地为您添加CSS样式headerfooter如下所示:

header {
  width:100%;
  height:20%; //your desired height
  position:absolute;
  top:0;
  left:0;
  background-color:blue;
}

footer{
  width:100%;
  height:20%; //your desired height
  position:absolute;
  bottom:0;
  left:0;
  background-color:blue;
}

SEE THIS DEMO

另一种方法是将页眉,页脚和正文分成三个不同的div:

<html>
  <head></head>
  <body>
    <div id="body">
      <div id="header">your header content</div>
      <div id="bodycontainer">your body content</div>
      <div id="footer">your footer content</div>
    </div>
  </body>
</html>

要使用页面的整个宽度显示页眉和页脚,请使用以下CSS:

#body
{
  width:100%;
  height:100%;  // the desired height
  position:absolute;
  top:0;
  left:0;
}

#header
{
  width:100%;
  height:20%;   // the desired height
  position:absolute;
  top:0;
  left:0;
  background-color:blue;
}

#footer
{
  width:100%;
  height:20%;   // the desired height
  position:absolute;
  bottom:0;
  left:0;
  background-color:blue;
}

页眉位于页面顶部,页脚位于页面底部。两者都使用整个屏幕宽度。

检查这个小提琴:

简单演示

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何将HTML页眉和页脚添加到页面?

来自分类Dev

如何将页眉和页脚添加到生成的PDF中

来自分类Dev

Yii2如何将布局文件拆分为单独的页眉和页脚?

来自分类Dev

定位全宽页眉

来自分类Dev

将iFrame设置为固定页脚和页眉之间的全高

来自分类Dev

将iFrame设置为固定页脚和页眉之间的全高

来自分类Dev

如何将本机按钮设置为全宽

来自分类Dev

显示:网格。如何将块拉伸到全宽

来自分类Dev

如何将“ \”更改为“ /”

来自分类Dev

如何将vim中的某些关键字更改为全大写?

来自分类Dev

全宽页脚引导

来自分类Dev

CSS问题:如何将<div>元素(<div>,页眉,页脚和正文)与响应式网页设计垂直对齐?

来自分类Dev

如何将时间和日期语言更改为英语?

来自分类Dev

如何将AsyncTask更改为@background和@UiThread

来自分类Dev

全页高度,带有固定的页眉和页脚

来自分类Dev

如何使用Angularjs包含页眉和页脚?

来自分类Dev

OpenOffice API:如何关闭页眉和页脚

来自分类Dev

如何分隔页眉正文和页脚

来自分类Dev

如何从PDF删除页眉和页脚?

来自分类Dev

我如何将 about 部分放在页眉下但在页脚之上?

来自分类Dev

如何将1更改为00001?

来自分类Dev

如何将Stringtokenizer更改为String

来自分类Dev

如何将活动更改为片段

来自分类Dev

如何将$ allUsers = []更改为array()?

来自分类Dev

如何将onClick更改为EditTextPreference?

来自分类Dev

如何将id更改为相同

来自分类Dev

如何将foreach更改为for循环?

来自分类Dev

如何将Byobu提示从“>”更改为“ $”?

来自分类Dev

如何将悬停更改为onclick