HTML & CSS 背景

标签 html css

我是 CSS 的新手,我想知道如何实现这一点:

我正在编写一个页面,该页面将在中间显示一个表单(由黑框表示)。我希望它具有与主体背景重叠的白色背景(由红线表示)。

查看此站点以获取示例图像。 (对不起,我无法在线发布)

http://www.freeimagehosting.net/uploads/bf2d71f238.png

非常感谢!

最佳答案

你可以给你的元素一些样式,背景可以是颜色、图片等。

CSS:

body { /* Red Lines Here */
  background: #990000;
}
#outer { /* White box Here */
  background: #ffffff; /* White */
  width: 900px; /* Total width will be 1000px once you include padding */
  padding: 50px; /* White border around black box, this is padding on all sides */
  margin: 0 auto; /* Centering it */
}
#inner { /*Black Box Here */
  background: #000000; /* Black */     
  color: #ffffff; /* White Text so you can see it */ 
}

HTML:

<html>
  <head>
    <title>My Page! Step off!</title>
  </head>
  <body>
    <div id="outer">
      <div id="inner">
        Content!
      </div>
    </div>
  </body>
</html>

关于HTML & CSS 背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2225836/

相关文章:

javascript - 当它更改为输入字段时,如何获得相同的 DIV 名称或 id

typography - 传统行距和 CSS 行高

jquery - 将鼠标悬停在某个非 slider div 上时如何暂停 nivo slider ?

html - 在父 div 中定位内部 div

javascript - 剑道指令不起作用

html - 使用 Google Charts 扩展轴

html - 悬停菜单列表出现闪烁的故障

html - 将 float 元素放在其父元素的底部

jquery - 使用 SmartBanner 将横幅保留在网站标题上方

javascript - 新iPad(iPad 3),如何处理图像?自动加载正确大小的 JS 脚本?