does angular material have a grid system?

前端 未结 3 1053
忘掉有多难
忘掉有多难 2021-02-04 01:28

I\'m starting a project with angular material. Does it have a native system for positioning elements in a responive grid like bootstrap does ?

Otherwise is it ok practic

3条回答
  •  耶瑟儿~
    2021-02-04 01:53

    This site describes how to add the bootstrap grid to a Angular Material project: https://www.amadousall.com/the-good-parts-of-bootstrap-4-you-are-missing-in-your-angular-material-projects/

    A summary of the steps described in the article:

    Add bootstrap to your project:

    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:

    The _variables.scss Sass partial allows us to customize Bootstrap - more precisely, the parts of Bootstrap that we will be using

    $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:

    The _reset.scss Sass partial allows us to override some of the Bootstrap styles we don't want

    * {
      &: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
    }
    

提交回复
热议问题