Getting responsive with Flex
Some CSS using flex¶
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: verdana;
}
h1 {
text-align: center;
}
h2 {
margin: 0;
background: gray;
color: white;
padding: 5px;
}
p {
margin: 2px 5px;
}
main {
font-size: 80%;
border: 1px solid green;
padding: 12px;
width: 75%;
margin: 0 auto;
display: flex;
justify-content: center;
flex-direction: row;
flex-wrap: wrap;
}
.info {
border: 2px solid silver;
margin: 12px;
flex-basis: 280px;
}
Media Queries¶
@media (max-width: 500px) {
main {
width: 100%;
}
.info {
flex-basis: 100%;
}
}
You can see a Codepen example here