在主容器外设置页面的背景色

Luk*_*sey 3 html css twitter-bootstrap twitter-bootstrap-3

我使用的是Narrow Jumbotron Bootstrap示例,您如何设置页面周围内容的背景颜色,而将主要内容保持在中心白色。更改主体的背景颜色会将所有内容更改为该颜色,包括导航栏。

基本上,我只想更改两侧的颜色,而不是中间的内容。

Tho*_*mas 6

设置background-colorbody.containerDIV:

body {
    background-color: tomato;
}

.container {
    background-color: white;
}
Run Code Online (Sandbox Code Playgroud)

此外,要删除容器顶部和底部的彩色线,请删除paddingbody并将其应用于.container

body {
    padding: 0;
}

.container {
    padding-top: 20px;
    padding-bottom: 20px;
}
Run Code Online (Sandbox Code Playgroud)