In this screencast we'll dig into the Deals section. The Deals section is essentially a "wall of ads". It's an area of the site that people would have to navigate to themselves, so I'm not worried about jamming ads down peoples thoughts. Also, each ad has a discount on it and is product that I personally recommend, so no shady-ness going on.

We already have the header in place. We also already have the content being spit out onto the page that we need to style. This is the perfect place to be to launch right into writing some CSS.

What's cool about this page is that we can dip our toes into the world of responsive advertising. The advertising world really hasn't caught up with responsive design. Ads are often of fixed size and resizing them is difficult or straight up forbidden. That's not the case on this site because I create the ads myself.

Each ad is created from a background image, a logo image, and bits of text. Using a background-image means we can kinda crop the edges of it and that's OK. We don't lose any text or important parts of the logo.

The layout of this "wall" will be wall-like =). We'll have it be three columns at wide desktop sizes and then go down to two columns and then finally a single column at phone-ish sizes. All we do is float the ads and apply a min-height to keep them all the same height. At different media queries, we simply adjust the widths of the ads and change which of them have right margin and which do not (via :nth-child).

On the back end, each ad is a custom field in WordPress. When we output them onto the page we first query for them and put them into an array. Then shuffle that array. Then finally echo them out. Might as well give everyone a fair shot at being the top ad!

Submit a Comment

Posting Code

You may write comments in Markdown. This makes code easy to post, as you can write inline code like `<div>this</div>` or multiline blocks of code in triple backtick fences (```) with double new lines before and after.

Code of Conduct

Absolutely anyone is welcome to submit a comment here. But not all comments will be posted. Think of it like writing a letter to the editor. All submitted comments will be read, but not all published. Published comments will be on-topic, helpful, and further the discussion or debate.

Want to tell us something privately?

Feel free to use our contact form. That's a great place to let us know about typos or anything off-topic.

icon-anchoricon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag