Skip to content

Instantly share code, notes, and snippets.

@shiguruikai
Created July 24, 2023 05:10
Show Gist options
  • Save shiguruikai/d8910b54a719057b808243c84f3cfc30 to your computer and use it in GitHub Desktop.
Save shiguruikai/d8910b54a719057b808243c84f3cfc30 to your computer and use it in GitHub Desktop.
Angular Flex-Layout の代替(すべてを網羅しているわけではありません)
// Angular Flex-Layout の代替
[fxLayout] {
box-sizing: border-box;
display: flex;
}
[fxLayout^='row'] {
flex-direction: row;
}
[fxLayout^='row-reverse'] {
flex-direction: row-reverse;
}
[fxLayout^='column'] {
flex-direction: column;
}
[fxLayout^='column-reverse'] {
flex-direction: column-reverse;
}
[fxLayout$=' nowrap'] {
flex-wrap: nowrap;
}
[fxLayout$=' wrap'] {
flex-wrap: wrap;
}
[fxLayout$=' wrap-reverse'] {
flex-wrap: wrap-reverse;
}
[fxLayoutAlign] {
box-sizing: border-box;
display: flex;
align-content: stretch;
align-items: stretch;
justify-content: flex-start;
}
[fxLayoutAlign^='start'] {
justify-content: flex-start;
}
[fxLayoutAlign^='center'] {
justify-content: center;
}
[fxLayoutAlign^='end'] {
justify-content: flex-end;
}
[fxLayoutAlign^='space-around'] {
justify-content: space-around;
}
[fxLayoutAlign^='space-between'] {
justify-content: space-between;
}
[fxLayoutAlign^='space-evenly'] {
justify-content: space-evenly;
}
[fxLayoutAlign$=' start'] {
align-content: flex-start;
align-items: flex-start;
}
[fxLayoutAlign$=' center'] {
align-content: center;
align-items: center;
}
[fxLayoutAlign$=' end'] {
align-content: flex-end;
align-items: flex-end;
}
[fxLayoutAlign$=' space-around'] {
align-content: space-around;
align-items: space-around;
}
[fxLayoutAlign$=' space-between'] {
align-content: space-between;
align-items: space-between;
}
[fxLayoutAlign$=' baseline'] {
align-content: stretch;
align-items: baseline;
}
[fxLayout^='row'][fxLayoutAlign$=' stretch'] {
max-height: 100%;
}
[fxLayout^='column'][fxLayoutAlign$=' stretch'] {
max-width: 100%;
}
[fxFlex] {
box-sizing: border-box;
flex: 1 1 0%;
}
[fxFlex='grow'] {
flex: 1 1 100%;
}
[fxFlex='initial'] {
flex: 0 1 auto;
}
[fxFlex='none'] {
flex: 0 0 auto;
}
[fxFlex='nogrow'] {
flex: 0 1 auto;
}
[fxFlex='auto'] {
flex: 1 1 auto;
}
[fxFlex='noshrink'] {
flex: 1 0 auto;
}
@mixin flex {
@for $i from 0 through 100 {
[fxLayout^='row'] > [fxFlex='#{$i}'] {
box-sizing: border-box;
flex: 1 1 $i * 1%;
max-width: $i * 1%;
}
[fxLayout^='column'] > [fxFlex='#{$i}'] {
box-sizing: border-box;
flex: 1 1 $i * 1%;
max-height: $i * 1%;
}
}
}
@include flex;
[fxFlexFill],
[fxFill] {
width: 100%;
min-width: 100%;
height: 100%;
min-height: 100%;
margin: 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment