Lev*_*Lev 10 css twitter-bootstrap material-design angular-material2
我正在开始一个有角度材料的项目.它是否有一个原生系统用于在响应网格中定位元素,如bootstrap?
否则,将材料设计与引导程序结合用于网格系统是否可行?
也许我对这个问题采取了错误的方法.
Neh*_*hal 13
如果您使用的是Material2,则可以使用Angular Flex Layout进行响应.它很好地补充了Angular2并且轻巧.
基本上,Material2 + Flex-layout等同于Bootsrap库.
这是一个如何使用Angular/Material2将flex-layout用于网格系统/响应的示例.
示例代码显示了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>
Run Code Online (Sandbox Code Playgroud)
Toa*_*oul 11
该站点描述了如何将引导网格添加到 Angular Material 项目:https : //www.amadousall.com/the-good-parts-of-bootstrap-4-you-are-missing-in-your-angular-material -项目/
文章中描述的步骤摘要:
将引导程序添加到您的项目:
npm install bootstrap --save
@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';
Run Code Online (Sandbox Code Playgroud)
_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
);
Run Code Online (Sandbox Code Playgroud)
_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
}
Run Code Online (Sandbox Code Playgroud)