html - 如何在 html 中只为屏幕未使用的部分着色?

标签 html css

我正在尝试构建一个网页。我要代码

<header>
    Some content
</header>
<body>
    More content
</body>

放置在屏幕中间,只占屏幕的一小部分 屏幕的宽度。我希望屏幕的其余部分为灰色。

基本上,我希望该页面具有与 this one 相似的外观.

这样做的简单方法是什么?

最佳答案

您必须将所有内容包装在 1 个主 div 中并为其指定最大宽度,例如 1200 像素。然后像这样为你的 body 设置颜色:

    body {
        background-color: #eee;
    }
    #main {
        max-width: 900px;
        background-color: #fff;
        margin: 0 auto; 
    }

关于html - 如何在 html 中只为屏幕未使用的部分着色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52652848/

相关文章:

css - ASP.NET 中的 Bootstrap 模板 : Blank spaces around the template

javascript - 点击事件触发 child ?

javascript - 一个或多个保留位在 : reserved1 = 0, reserved2 = 1, reserved3 = 1

html - 解决这个 HTML/CSS 问题?

html - 将点击发送到 google 的 chrome 输入 html 标签

css - 在 chrome 中调整窗口大小时字体不显示

jquery - 如何在特定屏幕宽度的输入字段左侧打开 Bootstrap 日期选择器

javascript - 当我添加图形标题时,响应式(Reactive)汉堡包菜单中断

html - 可滚动表格 css,如何设置百分比宽度?

javascript - 延迟显示 iframe 'preview' 弹出窗口