html - 需要背景颜色来填充空间

标签 html css angular8

我的背景色属性没有完全填满空间(见图)Background not filling (图像显示右侧和顶部的页面内容,但背景颜色未填充空白区域)

代码如下:

<body style="background-color: #163a4b; color: white">
    <app-navbar></app-navbar>
    <div style="margin: 15px">
        <router-outlet></router-outlet>
    </div>
</body>

<body style="background-color: #163a4b; color: white">
    <app-navbar></app-navbar>
    <div style="margin: 15px">
        <router-outlet></router-outlet>
    </div>
</body>

最佳答案

所需的添加是在 index.html 而不是组件的 HTML 上做背景色。这将解决问题。

之前(app.component.html)

<body style="background-color: #163a4b; color: white">
    <app-navbar></app-navbar>
    <div style="margin: 15px">
        <router-outlet></router-outlet>
    </div>
</body>

在 (index.html) 之后

<!doctype html>
<html lang="en">
<body style="background-color: #163a4b;">
  <app-root></app-root>
</body>
</html>

关于html - 需要背景颜色来填充空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57645684/

相关文章:

javascript - Angular Controller 中的 $scope 变量未在 HTML 中显示

html - Gmail 在 HTML 电子邮件中的图像周围放置间距

angular - 从 Angular 8 的下拉列表中删除/禁用选定的选项(动态创建的)

html - Powershell 2.0 - 使用 HtmlAgilityPack 获取 FORM 元素的子元素

html - 横跨整行 CSS GRID 的水平边框

css - 绘制如图所示的图像

firefox - 边框图像属性在 Mozilla Firefox 中不起作用

javascript - 将鼠标悬停在图像的某个部分时,使它旁边出现一个 div

javascript - Angular 8 组件嵌套在同一个组件事件发射器中