Created
May 20, 2019 20:00
-
-
Save sharjeel619/658cd302a7be3c8ed4299f91a36e1ea4 to your computer and use it in GitHub Desktop.
Display items in a grid using display: grid, without any media queries
This file contains 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
<html> | |
<head> | |
<title>CSS Grid</title> | |
<style> | |
.grid { | |
display: grid; | |
grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); | |
grid-gap: 15px; | |
} | |
.grid div { | |
background: black; | |
margin-top: 15px; | |
width: 100%; | |
max-width: 350px; | |
height: 250px; | |
color: #fff; | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
font-size: 30px; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="grid"> | |
<div>1</div> | |
<div>2</div> | |
<div>3</div> | |
<div>4</div> | |
<div>5</div> | |
<div>6</div> | |
<div>7</div> | |
<div>8</div> | |
<div>9</div> | |
<div>10</div> | |
<div>11</div> | |
<div>12</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment