Angular 4组件未水平填充

时间:2017-10-10 05:38:47

标签: javascript html css angular width

enter image description here 所以我希望图像和导航栏文本水平填充整个屏幕,但无法找到方法。我已经使用CSS属性边框填充和宽度来尝试扩展导航栏元素的背景,但似乎没有任何改变它;元素始终以边框为中心。

这只发生在我将代码从HTML / CSS转换为Angular之后;当我没有把它放在组件中时,这就是我的代码的样子:

有谁知道如何解决这个问题?提前谢谢

Components

content_component.html <!-- Intro Header -->
<div class="all">
<header class="masthead">
  <div class="intro-body">
    <div class="container">
      <div class="row">
        <div class="col-lg-8 mx-auto">
          <a href="#about" class="btn btn-circle js-scroll-trigger">
            <i class="fa fa-angle-double-down animated"></i>
          </a>
        </div>
      </div>
    </div>
  </div>
</header>

  <!-- About Section -->
  <section id="about" class="content-section text-center">
    <div class="container">
      <div class="row">
        <div class="col-lg-8 mx-auto">
          <h2>About Me</h2>
          <p>
            hello
          </p>
        </div>
      </div>
    </div>
  </section>
</div>

content_component.css
    .all{
      height:100%;
      background: black;
      color: white;
      margin: 0;

    }

    .masthead{
      display: table;

      overflow:auto;
      padding-left: 0px;
      padding-right: 0px;
      padding-top: 100px;
      padding-bottom: 600px;

      text-align: center;

      color: white;
      background: url('../../img/intro-bg.jpg') no-repeat bottom center scroll;
      background-size: 100%;
      background-color: black;
      -webkit-background-size: cover;
      -moz-background-size: cover;
      -o-background-size: cover;
      background-size: cover;
      .intro-body {
        display: table-cell;

        vertical-align: middle;
        .brand-heading {
          font-size: 50px;
        }
        .intro-text {
          font-size: 18px;
        }
      }
      @media(min-width:768px) {
        height: 100%;
        padding: 0;
        .intro-body {
          .brand-heading {
            font-size: 100px;
          }
          .intro-text {
            font-size: 22px;
          }
        }
      }
    }

app_component.css
    .container{
    }
    html{
      margin:auto;
      overflow: hidden;
    }

1 个答案:

答案 0 :(得分:0)

您可以将身体边距设置为自动 https://jsfiddle.net/wxmsud1d/

body {
  margin:auto;
}
header {
  background-color:red;
}

<header>Text goes here</header>