Last active
July 23, 2022 03:02
-
-
Save zuramai/1c0b0501a79b3ba959b2a3922429c775 to your computer and use it in GitHub Desktop.
Base Responsive Flex CSS Without Bootstrap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* { | |
padding: 0; | |
margin: 0; | |
box-sizing: border-box; | |
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; | |
} | |
.row { | |
margin: 0 -1rem; | |
display:flex; | |
flex-wrap: wrap; | |
} | |
.row + .row { | |
margin-top: 1rem; | |
} | |
[class*='col-'] { | |
padding: 0 1rem; | |
} | |
.container { | |
width: 100%; | |
padding: 0 1rem; | |
margin: 0 auto; | |
} | |
.mx-auto { | |
margin: 0 auto; | |
} | |
.col-1 { flex: none; width: calc(100% * 1 / 12) } | |
.col-2 { flex: none; width: calc(100% * 2 / 12) } | |
.col-3 { flex: none; width: calc(100% * 3 / 12) } | |
.col-4 { flex: none; width: calc(100% * 4 / 12) } | |
.col-5 { flex: none; width: calc(100% * 5 / 12) } | |
.col-6 { flex: none; width: calc(100% * 6 / 12) } | |
.col-7 { flex: none; width: calc(100% * 7 / 12) } | |
.col-8 { flex: none; width: calc(100% * 8 / 12) } | |
.col-9 { flex: none; width: calc(100% * 9 / 12) } | |
.col-10 { flex: none; width: calc(100% * 10 / 12) } | |
.col-11 { flex: none; width: calc(100% * 11 / 12) } | |
.col-12 { flex: none; width: calc(100% * 12 / 12) } | |
@media screen and (min-width: 554px) { | |
.col-xs-1 { flex: none; width: calc(100% * 1 / 12); } | |
.col-xs-2 { flex: none; width: calc(100% * 2 / 12); } | |
.col-xs-3 { flex: none; width: calc(100% * 3 / 12); } | |
.col-xs-4 { flex: none; width: calc(100% * 4 / 12); } | |
.col-xs-5 { flex: none; width: calc(100% * 5 / 12); } | |
.col-xs-6 { flex: none; width: calc(100% * 6 / 12); } | |
.col-xs-7 { flex: none; width: calc(100% * 7 / 12); } | |
.col-xs-8 { flex: none; width: calc(100% * 8 / 12); } | |
.col-xs-9 { flex: none; width: calc(100% * 9 / 12); } | |
.col-xs-10 { flex: none; width: calc(100% * 10 / 12); } | |
.col-xs-11 { flex: none; width: calc(100% * 11 / 12); } | |
.col-xs-12 { flex: none; width: calc(100% * 12 / 12); } | |
} | |
@media screen and (min-width: 640px) { | |
.container { | |
max-width: 640px; | |
} | |
.col-sm-1 { flex: none; width: calc(100% * 1 / 12); } | |
.col-sm-2 { flex: none; width: calc(100% * 2 / 12); } | |
.col-sm-3 { flex: none; width: calc(100% * 3 / 12); } | |
.col-sm-4 { flex: none; width: calc(100% * 4 / 12); } | |
.col-sm-5 { flex: none; width: calc(100% * 5 / 12); } | |
.col-sm-6 { flex: none; width: calc(100% * 6 / 12); } | |
.col-sm-7 { flex: none; width: calc(100% * 7 / 12); } | |
.col-sm-8 { flex: none; width: calc(100% * 8 / 12); } | |
.col-sm-9 { flex: none; width: calc(100% * 9 / 12); } | |
.col-sm-10 { flex: none; width: calc(100% * 10 / 12); } | |
.col-sm-11 { flex: none; width: calc(100% * 11 / 12); } | |
.col-sm-12 { flex: none; width: calc(100% * 12 / 12); } | |
} | |
@media screen and (min-width: 768px) { | |
.container { | |
max-width: 768px; | |
} | |
.col-md-1 { flex: none; width: calc(100% * 1 / 12) } | |
.col-md-2 { flex: none; width: calc(100% * 2 / 12) } | |
.col-md-3 { flex: none; width: calc(100% * 3 / 12) } | |
.col-md-4 { flex: none; width: calc(100% * 4 / 12) } | |
.col-md-5 { flex: none; width: calc(100% * 5 / 12) } | |
.col-md-6 { flex: none; width: calc(100% * 6 / 12) } | |
.col-md-7 { flex: none; width: calc(100% * 7 / 12) } | |
.col-md-8 { flex: none; width: calc(100% * 8 / 12) } | |
.col-md-9 { flex: none; width: calc(100% * 9 / 12) } | |
.col-md-10 { flex: none; width: calc(100% * 10 / 12) } | |
.col-md-11 { flex: none; width: calc(100% * 11 / 12) } | |
.col-md-12 { flex: none; width: calc(100% * 12 / 12) } | |
} | |
@media screen and (min-width: 1024px) { | |
.container { | |
max-width: 1024px; | |
} | |
.col-lg-1 { flex: none; width: calc(100% * 1 / 12) } | |
.col-lg-2 { flex: none; width: calc(100% * 2 / 12) } | |
.col-lg-3 { flex: none; width: calc(100% * 3 / 12) } | |
.col-lg-4 { flex: none; width: calc(100% * 4 / 12) } | |
.col-lg-5 { flex: none; width: calc(100% * 5 / 12) } | |
.col-lg-6 { flex: none; width: calc(100% * 6 / 12) } | |
.col-lg-7 { flex: none; width: calc(100% * 7 / 12) } | |
.col-lg-8 { flex: none; width: calc(100% * 8 / 12) } | |
.col-lg-9 { flex: none; width: calc(100% * 9 / 12) } | |
.col-lg-10 { flex: none; width: calc(100% * 10 / 12) } | |
.col-lg-11 { flex: none; width: calc(100% * 11 / 12) } | |
.col-lg-12 { flex: none; width: calc(100% * 12 / 12) } | |
} | |
@media screen and (min-width: 1280px) { | |
.container { | |
max-width: 1280px; | |
} | |
.col-xl-1 { flex: none; width: calc(100% * 1 / 12) } | |
.col-xl-2 { flex: none; width: calc(100% * 2 / 12) } | |
.col-xl-3 { flex: none; width: calc(100% * 3 / 12) } | |
.col-xl-4 { flex: none; width: calc(100% * 4 / 12) } | |
.col-xl-5 { flex: none; width: calc(100% * 5 / 12) } | |
.col-xl-6 { flex: none; width: calc(100% * 6 / 12) } | |
.col-xl-7 { flex: none; width: calc(100% * 7 / 12) } | |
.col-xl-8 { flex: none; width: calc(100% * 8 / 12) } | |
.col-xl-9 { flex: none; width: calc(100% * 9 / 12) } | |
.col-xl-10 { flex: none; width: calc(100% * 10 / 12) } | |
.col-xl-11 { flex: none; width: calc(100% * 11 / 12) } | |
.col-xl-12 { flex: none; width: calc(100% * 12 / 12) } | |
} | |
@media screen and (min-width: 1536px) { | |
.container { | |
max-width: 1536px; | |
} | |
.col-xxl-1 { flex: none; width: calc(100% * 1 / 12) } | |
.col-xxl-2 { flex: none; width: calc(100% * 2 / 12) } | |
.col-xxl-3 { flex: none; width: calc(100% * 3 / 12) } | |
.col-xxl-4 { flex: none; width: calc(100% * 4 / 12) } | |
.col-xxl-5 { flex: none; width: calc(100% * 5 / 12) } | |
.col-xxl-6 { flex: none; width: calc(100% * 6 / 12) } | |
.col-xxl-7 { flex: none; width: calc(100% * 7 / 12) } | |
.col-xxl-8 { flex: none; width: calc(100% * 8 / 12) } | |
.col-xxl-9 { flex: none; width: calc(100% * 9 / 12) } | |
.col-xxl-10 { flex: none; width: calc(100% * 10 / 12) } | |
.col-xxl-11 { flex: none; width: calc(100% * 11 / 12) } | |
.col-xxl-12 { flex: none; width: calc(100% * 12 / 12) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment