角材料有网格系统吗?

新手上路,请多包涵

我正在用角材料开始一个项目。它是否有像 bootstrap 那样在响应式网格中定位元素的本机系统?

否则,将材料设计与网格系统的引导程序结合起来是否可行?

也许我对这个问题采取了错误的方法。

原文由 Lev 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 698
2 个回答

如果您使用的是 Material2,则可以使用 Angular Flex Layout 来实现响应。它很好地补充了 Angular2 并且重量轻。

基本上 Material2 + Flex-layout 相当于 Bootsrap 库。

这是 flex-layout 如何用于 Angular/Material2 的网格系统/响应性的 示例

显示使用 flex-layout API 的示例代码:

 <div fxShow.xs="true" fxShow="false" >Screen size <h1>XS</h1></div>
    <div fxShow.sm="true" fxShow="false" >Screen size <h1>SM</h1></div>
    <div fxShow.md="true" fxShow="false" >Screen size <h1>MD</h1></div>
    <div fxShow.lg="true" fxShow="false" >Screen size <h1>LG</h1></div>
    <div fxShow.xl="true" fxShow="false" >Screen size <h1>XL</h1></div>

    <div fxLayout="row"
         fxLayout.xs="column"
         fxLayoutGap="10px"
         fxLayoutAlign.xs="center center"
         fxLayoutWrap>
      <div class="sample-div" fxFlexOrder.lt-md="7">Div 1</div>
      <div class="sample-div" fxFlexOrder.lt-md="6">Div 2</div>
      <div class="sample-div" fxFlexOrder.lt-md="5">Div 3</div>
      <div class="sample-div" fxFlexOrder.lt-md="4">Div 4</div>
      <div class="sample-div" fxFlexOrder.lt-md="3">Div 5</div>
      <div class="sample-div" fxFlexOrder.lt-md="2">Div 6</div>
      <div class="sample-div" fxFlexOrder.lt-md="1">Div 7</div>
      <div class="sample-div" fxFlexOrder.lt-md="0">Div 8</div>
    </div>

原文由 Nehal 发布,翻译遵循 CC BY-SA 3.0 许可协议

该站点描述了如何将引导网格添加到 Angular Material 项目: https ://www.amadousall.com/the-good-parts-of-bootstrap-4-you-are-missing-in-your-angular-material -项目/

文章中描述的步骤摘要:

将引导程序添加到您的项目中:

npm install bootstrap –save

src/styles.scss:

 @import '~@angular/material/prebuilt-themes/indigo-pink.css';

@import 'variables';

// Imports functions, variables, and mixins that are needed by other Bootstrap files
@import '~bootstrap/scss/functions';
@import '~bootstrap/scss/variables';
@import '~bootstrap/scss/mixins';
// Import Reboot
@import '~bootstrap/scss/reboot';
@import '~bootstrap/scss/grid'; // add the grid
@import '~bootstrap/scss/utilities'; // add css utilities

@import 'reset';

src/_variables.scss:

_variables.scss Sass 部分允许我们自定义 Bootstrap - 更准确地说,是我们将使用的 Bootstrap 部分

$link-color: #3f51b5;
$link-hover-color: currentColor;
$link-hover-decoration: none;

$grid-breakpoints: (
  xs: 0, // handset portrait (small, medium, large) | handset landscape (small)
  sm: 600px, // handset landscape (medium, large) | tablet portrait(small, large)
  md: 960px, //  tablet landscape (small, large)
  lg: 1280px, // laptops and desktops
  xl: 1600px // large desktops
);

$container-max-widths: (
  sm: 600px,
  md: 960px,
  lg: 1280px,
  xl: 1600px
);

src/_reset.scss:

_reset.scss Sass 部分允许我们覆盖一些我们不想要的 Bootstrap 样式

* {
  &:active,
  :focus {
    outline: none !important;  // 1
  }
}

label {
  margin-bottom: 0; // 2
}

a:not(.mat-button):not(.mat-raised-button):not(.mat-fab):not(.mat-mini-fab):not([mat-list-item]) {
  color: #3f51b5; // 3
}

原文由 ToastedSoul 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题