====== Creating RWD Banners (or other RWD content) ====== **Note:** This page is specifically made for instructing on how to show a larger banner for larger screens, and a smaller banner for smaller screens. But these same principles can be used for creating any custom content / layout that you wish to be "responsive" to the screen size. In fact, when our developers originally created the new default RWD templates and CSS, they followed the exact same basic underlying steps as illustrated below. **About using RWD:** You will **not** find one large section of CSS for "one common device size" and another for "another common size". Instead you will see several different break-point media queries in the default CSS that are based around the content and what layout works best for that content depending on the screen size. This approach is important now and even more so in the future, because there are so many different devices that all have different screen sizes. There is no longer one "standard" size for mobile phones, one "standard" for tablets, these days mobile devices come in all shapes and sizes. Well, testing at several "common sizes" is a good idea, but it is very important to recognize those are not the "only" sizes out there, and it is not a good idea to base designs 100% on those common sizes. Instead base them on what looks good for the content. In other words, base the break-point sizes on what looks good for the content, not based on specific common device sizes. We have several different "break points" that are based on when that "thing" needs to be switched from one layout to another... And since there is not just "one for mobile, one for desktop" type of mentality, a lot of times when you are adding your own custom content, it is a good idea to do the same thing rather than just tacking on to one of the other break-points that already exist. If your own content is somehow interconnected to the default layout, for instance it needs to be displayed above the menu in larger screens but once the menu changes to a top menu bar, switch to another layout, by all means use the same breakpoints as the default design. But if the content you are adding is independent, **we would recommend to find your own best break-points as is described on this page**. **Warning:** This method results in a banner ad being hidden using CSS (based on screen size). If you are using an ad company (like Google Ads) rather than banner management software (like Adpeeps), check their Terms of Service (TOS) or user agreements to make sure doing so is not against the TOS. You may want to contact them directly if you are not sure, and be sure to explain this is purely so that it can show the right sized banner based on the screen size, one banner will be hidden while the other is displayed. Times that it is against the TOS are usually to prevent you from hiding the banner and still getting credit for impressions or something similar to that. ====== Overall Steps ====== These are the overall basic steps simplified, see the proceeding sections on this page for detailed explanation of each step. While the specific examples given will instruct you how to set up different banner sizes to show on different screen sizes, these overall steps can be used for any type of custom content being added to the page. - First, set up the "global" CSS that will apply for any screen size. - Create a break-point and set up the CSS that will "overwrite" the global CSS when the screen is large enough. During this stage use a break-point of 1em. - After both "versions" of the CSS are complete, "dial in" the break-point size based on what looks best. - Test everything on multiple screen sizes, multiple browsers, and if you have access, multiple devices (mobile and tablet). ===== Step 1: Create Global (Smallest Screen Size) CSS ===== First, you will set up the overall "global" CSS that will apply for any screen size. But note that parts of it are "overwritten" for larger screen sizes, it is still best to think of this as the global CSS so that you don't forget that it will apply to all sizes if there is not something overwriting it. In other words, this is going to be the CSS used for smaller screen sizes, but also larger screen sizes for any parts of the CSS that are not overwritten in a media query break-point. So for this example, we'll set up 2 classes, one for the "large" banner and one for the "small" banner size. The CSS may look something like this: /* ========================================================================== Custom - Banners ========================================================================== */ .banner-small { /* small version of banner for smaller screens */ } .banner-large { /* large version of banner for larger screens, hide globally */ display: none; } This sets up 2 classes, **banner-small** for the smaller sized banner ads that would fit smaller screens, and **banner-large** for the full width banners that would fit better on larger sized screens or desktops. Now you add the HTML to the template, if you were adding it near the top of every page, you might add the HTML to **header.tpl**. You would add something like this: Be sure to insert the appropriate HTML snippet, provided by banner management software, in the applicable places within that snippet. Basically you add a
around the 2 snippets, the snippet for the smaller banner you use the banner-small class, the snippet for the larger banner you use the banner-large class on it's div tag. **Tip:** If you notice, there are no special "smarty tags" in that example HTML snippet. This is a good time to point out if you were not already aware, that with RWD, the HTML sent to the visitor's browser is exactly the same, no matter what screen size. The layout changes using CSS, not by using different HTML. Now view the page, and if you are on a desktop, make the screen width small, about 300 pixels or so to simulate what it might look like on smaller screens. If you need to add additional CSS style to the banner-small CSS, for instance if you want to make it center aligned or similar, do that now. Make sure it looks right in the smaller view, and that the "larger" banner ad is properly hidden. ===== Step 2: Create Break-Point(s) ===== In the **custom.css** file, right below the other CSS you just created, set up a media query break-point, starting off using "1em" as the minimum width for now until we dial in the exact size (next step). In this breakpoint, you will be hiding the smaller banner and showing the larger one. It should look something like this: @media only screen and (min-width: 1em) { /* ========================================================================== Custom Breakpoint for Banners ========================================================================== */ .banner-small { /* Hide the smaller banner on larger screens */ display: none; } .banner-large { /* Show the larger banner on larger screens */ display: block; } } **Tip:** Things in this section only need to overwrite what is changing from the "global" CSS. You will notice that it sets display:block for the "banner-large" style. This is because the main CSS we already added in step 1 acts "globally", and in the main CSS it sets display: none. So in order to make larger banner show on larger screens we must overwrite the display CSS by specifying display: block. This also means that for more complex CSS, you do NOT need to re-specify every single part of the CSS that is defined in the "global" CSS. If something does not need to change for larger views, there is no need to add that part. So for instance, if you specify "color: red" in the "global" CSS that is not inside a media query, and you want it to stay red in larger screens, you do not need the "color" in the media query because it is already set. Doing so is redundant((Much like this explanation)), if you already have something set for CSS "globally" and it is not changing for larger screens, you can keep it out of the media query section. Now that sets up a break-point at the 1em level, the EM unit is based on character width. So 1em is "1 character wide at the current font size". Yes that is way too small to be of any use, but it is just a temporary "start" to allow us to style things for the larger screen sizes. So now just as before, view the page, this time use the full desktop width. Make any adjustments to the CSS if needed so that things look just like you want. ==== Beyond the Banner ==== This section does not apply for the simple RWD banners, these are things you will need to know if creating more complex RWD contents. If you **need to adjust HTML**: Remember that you already set up what it looks like for smaller screens, so if you find that you need to adjust the HTML for whatever reason, be sure to re-test what it looks like on smaller screens. That is why it is important to use as "pure HTML markup" as possible, meaning to use HTML markup based on context, not on styles... For instance the default design primarily uses