![]() ![]() A lot of stuff is going on in that single property, so let’s go one step at a time. And that’s where the third line comes in.But these two lines don’t do anything on their own until we set the columns of our grid. The second line ( align-items: center ) is going to vertically center the columns on our grid.The first line ( display: grid ) is changing the behavior of the.We have a bunch of background styles to enable the beer background, a bit of padding to separate the content from the edge of the screen, and then three lines of grid styles: Grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)) hero element: Įxplore local breweries with just one click and stirred by starlight across the centuries light years great turbulent clouds circumnavigated paroxysm of global death. Let’s break down the code to see what’s going on: The hero section Though this might seem like a lot of code at first glance, the responsive behavior is done with only six lines of CSS Grid code, and without writing a single rule. ![]() We’ll kick off this set of examples by creating a common website layout: A full-width hero section, with a grid of cards below.īoth elements will respond to window resizing and adapt accordingly. Hero Content and List of Articles by Juan Martín García ( CodePen. Layout #1: Hero content and list of articles It’s easier than what you may think, and since CSS Grid was built with responsiveness in mind, it’ll take less code than writing media queries all over the place. In this article, we’ll start dipping our toes into the power of CSS Grid by building a couple of common responsive navigation layouts. What’s so cool about this era in web development is that we’re capable of doing more and more with fewer lines of code. Not only has CSS Grid reshaped the way we think and build layouts for the web, but it has also contributed to writing more resilient code, replacing “hacky” techniques we’ve used before, and in some cases, killing the need to rely on code for specific resolutions and viewports.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |