我是 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/