Skip to content

Instantly share code, notes, and snippets.

@wpflames
Created August 29, 2020 16:30
Show Gist options
  • Select an option

  • Save wpflames/17211ea3c0121997528264371bd94490 to your computer and use it in GitHub Desktop.

Select an option

Save wpflames/17211ea3c0121997528264371bd94490 to your computer and use it in GitHub Desktop.
Responsive Grid Layout UI Design - SCSS
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}
body{
display: flex;
justify-content: center;
align-items: center;
flex-wrap: wrap;
min-height: 100vh;
background: #0d1113;
.container{
position: relative;
width: 1000px;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
.card{
position: relative;
display: flex;
flex-direction: column;
background: #fff;
.imgBx{
position: relative;
width: 250px;
height: 250px;
img{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
}
}
&:nth-child(even){
flex-direction: column-reverse;
}
.content{
position: relative;
width: 250px;
height: 250px;
display: flex;
justify-content: center;
align-items: center;
div{
padding: 20px;
text-align: center;
}
}
}
}
}
/*ONLY MOBILE*/
@media (max-width: 1000px) {
body{
.container{
margin: 30px;
grid-template-columns: repeat(auto-fit, minmax(100%, 1fr));
gap: 10px;
.card{
flex-direction: row;
margin: 10px 0;
&:nth-child(even){
flex-direction: row-reverse;
}
.imgBx, .content{
width: 50%;
}
}
}
}
}/*END*/
@media (max-width: 600px) {
body{
.container{
.card{
flex-direction: column;
&:nth-child(even){
flex-direction: column;
}
.imgBx, .content{
width: 100%;
}
}
}
}
}/*END*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment