【问题标题】:Angular 4 Components not being filled horizontallyAngular 4组件未水平填充
【发布时间】:2017-10-10 23:26:07
【问题描述】:

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;
    }

【问题讨论】:

  • 请附上您的代码,否则根本无法说出它有什么问题。
  • 添加了代码。谢谢

标签: javascript html css angular width


【解决方案1】:

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

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

<header>Text goes here</header>

【讨论】:

  • 试过了,好像不行。我应该在应用组件 style.css 还是子组件样式中拥有这个?
猜你喜欢
  • 1970-01-01
  • 2018-04-02
  • 2021-02-25
  • 1970-01-01
  • 2011-09-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-08-08
相关资源
最近更新 更多