html - SASS/Flexbox 不工作

标签 html css sass flexbox predix

我正在尝试根据 this 将 flexbox 布局应用于我的元素例子。在 .html 中我有:

<link rel="import" href="seed-app-styles.html">
...
<template is="dom-if" if="{{isEqual(selected,'pacing')}}" restamp>
    <div class="px-login" id="pacing" class="flex flex--col flex--center flex--middle">
          <div>1</div>
          <div>2</div>
          <div>3</div>
    </div>        
</template>

我确实在 .scss 文件中启用了 flex:

@import "px-flexbox-design/_base.flexbox.scss";

但是,我仍然没有得到 flexbox:

enter image description here

并且这些类会生成到 seed-app-styles.html 中:

.flex {
  display: -ms-flexbox;
  display: flex; }

.inline--flex {
  display: -ms-inline-flexbox;
  display: inline-flex; }

.flex--row {
  -ms-flex-direction: row;
      flex-direction: row; }

我希望 div 居中。我在这里缺少什么?

没有 .css 文件 - 当我运行 gulp 时生成了一个 .html,这就是被导入的文件。

模板在index.html中使用:

<!DOCTYPE html>
<html>
<head>

...
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <link
    id="main-element-import"
    rel="import"
    href="/elements/seed-app/seed-app.html"
    async>

</head>
<body class="loading">        
  <seed-app></seed-app>

  <script src="/elements/dev-guide/dev-guide-bootstrap.js"></script>

</body>
</html>

最佳答案

我认为子项需要标记为flex__item。这是来自 predix-webapp-starter 的示例。

https://github.com/PredixDev/predix-webapp-starter/blob/master/public/elements/kpi-bar/kpi-bar.html

enter image description here

关于html - SASS/Flexbox 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50174853/

相关文章:

html - 调整第二列中元素的位置

html - CSS z-index 似乎没有响应

jquery - 反向 jquery 动画

CSS 重构 : SASS Mixins vs Multiple class

css - 没有 Ruby 的 SASS for .NET 应用程序

sass - 如何使用 grunt-sass 编译多个 scss 文件

jquery - 如何在html中制作相同的 slider

html - 我如何根据 Perl 中的类替换一些 HTML 标签?

css - 无法将 css 类应用到 WebGrid 中的 @Html.DisplayFor,在我的 asp.net MVC 5 Web 应用程序中

php - Laravel 多对多关系插入