【问题标题】:Angular 9, take up full width in componentAngular 9,在组件中占据全宽
【发布时间】:2020-09-27 04:05:54
【问题描述】:

我在获取我的一个角度模板文件中的内容以占据页面的整个宽度和高度时遇到问题。基本上我得到以下信息:

但我想要这样的东西: 我尝试将我的主 div 放在 template.html 中,宽度为:100%;但我没有任何区别。也许这与其他组件的样式有关。我不知道如何解决这个问题,任何帮助都会得到帮助!

这是显示的屏幕截图,这是导航栏和内容的 html、css。

header.html


<nav class="navbar navbar-default">
  <div class="container-fluid">
    <div class="navbar-header">
      <a class="navbar-brand">Brand</a>
    </div>
    <div class="navbar-collapse">
      <ul class="nav navbar-nav">
        <li routerLinkActive="active"><a routerLink="/link1" id="identified">Link 1</a></li>
        <li routerLinkActive="active"><a routerLink="/link2" id="identified">Link 2</a></li>
      </ul>
    </div>
  </div>
</nav>

header.css

.navbar-default {
  background-color: #7cd8fc;
}

.navbar-brand {
  color: white;
}
.navbar-brand:hover {
  color: white;
  background-color: #777799;
}
.navbar-brand:active {
  color: white;
}
#identified {
  color: black;
}
#identified:hover {
  background-color: #cadbda;
  /* background-color: #777799; */
}

* {
  font-family: Cambria; 
}

内容.html

<div class="container" style="width:100%;">
  text<br>
  text<br>
  text<br>
  text<br>
  text<br>
  text<br>
  text<br>
  text<br>
  text<br>
  text<br>
  text<br>
  text<br>
  text<br>
  text<br>
  text<br>
  text<br>
  text<br>
</div>

内容.css

(empty)

app.component.html

<app-header></app-header>
  <div class="container">
    <div class="row">
       <div class="col-md-12">
            <router-outlet></router-outlet>
        </div>
      </div>
  </div>

app.component.css

(empty)

违规展示:

【问题讨论】:

  • 请添加您的html和css代码
  • 我已经添加了相关代码,可能是我的app.component.html中的div

标签: angular formatting


【解决方案1】:

改变

<div class="container">

<div class="container-fluid">

引导容器类具有左右边距。使用流体容器创建一个没有边距的容器。

供参考https://getbootstrap.com/docs/4.0/layout/overview/#containers

【讨论】:

  • 是的,我已经编辑了它并且它有效!感谢您的帮助
猜你喜欢
  • 1970-01-01
  • 2022-01-25
  • 1970-01-01
  • 2015-11-26
  • 2020-01-04
  • 2016-09-10
  • 1970-01-01
  • 2020-09-24
  • 2020-06-26
相关资源
最近更新 更多