将网站的一部分设为白色

时间:2016-03-15 16:00:41

标签: html css

我正在设置此注册表单,并且我已将页面的背景设置为灰色。我希望中心区域,你应该填写信息,是白色的。我该怎么做?

我已经包含了网站现在看起来的图片,白色部分应该覆盖文本和所有框。 enter image description here

我的css代码为背景:

body{
background-color:#D2D7D3;
 background-size:1500px 1000px;
z-index:0
position:absolute;
}

1 个答案:

答案 0 :(得分:1)

这是你可以做的事情,将你的表单内容包装在div中并围绕它设置div。

这将在表单后面创建您想要的白色部分。

示例表格

<div class="form-container">
 <form>
  <label for="email"> Email </label>
  <input type="text" name="email"></input>

  <label for="password"> Password </label>
  <input type="text" name="password"></input>

  <button type="submit"> Register </button>
 </form>
</div>

在您的CSS中

.form-container {
  width: 300px;
  height: 300px;
  background-color: #fff;
}