<div class="boxes">
<button>Button 1</button>
<button>Button 2</button>
<button>Button 3</button>
<button>Button 4</button>
</div>
body {
font: normal 16px/1.5 "Helvetica Neue", sans-serif;
background: #1339AC;
color: #fff;
padding: 50px;
margin: 0;
}
.boxes button {
display: block;
width: 100%;
padding: 15px;
border: none;
margin-bottom: 5px;
box-sizing: border-box;
font-size: 1rem;
text-align: center;
text-decoration: none;
background: gold;
color: #000;
}
.boxes button:nth-of-type(even) {
background: #e6c200;
}
.boxes button:focus {
outline: none;
color: #fff;
background: firebrick;
}
@media screen and (min-width: 600px) {
.boxes {
display: grid;
grid-template-columns: repeat(4, 1fr);
}
.boxes button:nth-of-type(1) {
order: 4;
}
.boxes button:nth-of-type(2) {
order: 3;
}
.boxes button:nth-of-type(3) {
order: 2;
}
.boxes button:nth-of-type(4) {
order: 1;
}
}
// Use Chrome to test this example.
// Visit https://developers.google.com/web/updates/2014/03/Get-on-the-CSS-Grid?hl=en to enable the CSS Grid Layout for Chrome.
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.