【问题标题】:flexbox - Column contains div rows not workingflexbox - 列包含 div 行不起作用
【发布时间】:2018-06-23 14:27:51
【问题描述】:

目的:带有背景图像(封面)的 flexbox 页面,当屏幕缩小时,它的高度可能会增加,从而强制元素换行;但它的顶部有标题栏。

我将整个屏幕设置为带有背景图像的列。 列中的第一个元素:模拟标题栏。 第二个元素应该是一个 div - flex-direction: row,但里面的彩色 div 仍然表现得像在列中一样。

    html, body { box-sizing: border-box; height: 100%; width: 100%;
  margin: 0; padding: 0; border: 0; cursor: default }

.workspace {
  background: url("../../../assets/Images/WhatIsHunter2.jpg") no-repeat center center fixed;
  background-size: cover;
  height: 100vh;
  width: 100vw;

  h1 {
    color: #E0B228;
  }

  h2 {
    color: #2856E0;
  }
}

HTML:

<div class='workspace' [ngStyle]="{'display': 'flexbox', 'flex-direction': 'column'}">
  <div [ngStyle]="{'width': '100vw', 'height': '60px', 'background-color': 'beige'}">
    This is its own row at the top of the column - a header bar
  </div>
  <div [ngStyle]="{'margin-top': '20px', 'display': 'flexbox', 'flex-direction': 'row', 'justify-content': 'space-evenly'}">
    <div [ngStyle]="{'width': '100px', 'height': '100px', 'background-color': 'red'}">
    </div>
    <div [ngStyle]="{'width': '100px', 'height': '100px', 'background-color': 'green'}">
    </div>
    <div [ngStyle]="{'width': '100px', 'height': '100px', 'background-color': 'blue'}">
    </div>
  </div>
</div>

【问题讨论】:

  • 您的意思是 'display': 'flex' 而不是 'display': 'flexbox' 在您对父级的 ng 样式声明中?

标签: html angular css flexbox


【解决方案1】:

display: flexbox;改成display: flex;就可以了

【讨论】:

  • 哦!我应该抓住它。正是这种尴尬保证我永远不会再忘记那件事。非常感谢你的帮助。瑜伽士。
猜你喜欢
  • 2016-05-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-02-17
  • 2012-05-11
  • 2014-06-10
  • 1970-01-01
相关资源
最近更新 更多