我的背景色属性没有完全填满空间(见图) (图像显示右侧和顶部的页面内容,但背景颜色未填充空白区域)
代码如下:
<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/