改变页面宽度颜色背景

时间:2013-04-23 03:48:41

标签: html css

我出于非传统原因而追求HTML。我认为它在学术论文中提供了比MS Word或LaTeX更合适的游说,因为它为作者提供了更好的交流方式。我正在尝试编写一种可用于符合传统APA 6指南的学术论文的格式。

我想使用index.html文件或style.css(我不知道哪个更合适)使页面看起来像8.5宽纸(确切大小并不重要)而不是完整浅灰色背景上的宽度。这是在wordpress二十二主题中完成的,如下所示:

enter image description here

如何通过更改index.html文件(如下所示)来复制这种感觉,或者我需要在style.css文件中添加一些内容?具体来说,如何在顶部设置带有“页面”的彩色背景?

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>title</title>
    <link rel="stylesheet" href="style.css">
    <script src="script.js"></script>
  </head>
  <body>
    Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal. Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this.
  </body>
</html>

我试过偷了二十二个但是无法理解因为文件是php而且我不知道在style.scc文件中做了什么。

1 个答案:

答案 0 :(得分:2)

这是一个简单的例子......具体的规则很容易改变,但应该给你一个想法。基本上,您在正文的子元素(div.container)上设置小于100%的宽度。然后,将margin-leftmargin-right值设置为auto,以使其水平居中。设置为height:400px的{​​{1}}和margin-top以及margin-bottom是任意值。您的页面内容只需要在1em元素内构建...您的虚假页面。

演示:http://jsfiddle.net/ZXdY8/

<强> CSS

div.container

<强> HTML

body {
    background: #efefef;
}
.container {
    width: 90%;
    height: 400px;
    margin: 1em auto;
    background: #FFF;
}
.container p {
    padding: 1em;
}