<div class="grid">
<div class="grid__item grid__item--heading">
<h1>Negative grid lines</h1>
</div>
<div class="grid__item grid__item--img1"><img src='https://images.unsplash.com/photo-1462331940025-496dfbfc7564?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=d7f7ffaf8ae0edae20585d5b6d9d434e' alt='Space'></div>
<div class="grid__item grid__item--text">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<div class="grid__item grid__item--img2">
<img src='https://images.unsplash.com/photo-1516331138075-f3adc1e149cd?ixlib=rb-0.3.5&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ&s=ff6bd0faf3925ec9eff7c2315448c4ce' alt=''>
</div>
</div>
@import url("https://fonts.googleapis.com/css?family=Lato:400,400i,700");
* {
box-sizing: border-box;
}
body {
padding: 40px;
background-color: #1f2023;
color: #FAFAFA;
font-family: Lato, sans-serif;
}
h1 {
font-size: 3.5rem;
}
p {
font-size: 1.1rem;
line-height: 1.6;
}
img {
max-width: 100%;
display: block;
}
.grid {
display: grid;
grid-template-columns: repeat(12, 1fr);
grid-auto-rows: minmax(100px, auto);
grid-gap: 60px 20px;
@media (min-width: 60em) {
grid-template-columns: repeat(16, 1fr);
}
}
.grid__item--heading {
grid-column: 4 / -4;
text-align: center;
border-top: 2px solid;
border-bottom: 2px solid;
}
.grid__item--text {
grid-column: 2 / -2;
text-align: center;
}
.grid__item--img1 {
grid-column: 1 / span 8; // this item will always align to the start
}
.grid__item--img2 {
grid-column: span 8 / -1; // this item will always align to the end
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.