Full Background Image in Suffusion

Jul 032013
 
 Posted by on 03/07/2013 How-To's Tagged with: , , , ,  Add comments
Full Background Image
Full background image at any resolution or any level of zoom

Sometimes we need to use an image as background of site, but the image have some dimensions and it can’t fill the entire browser window, and it won’t be adjusted at any screen resolutions.

The reason for this behavior is that the picture is used as background-image for “body” tag, and a background image wasn’t able to fill the entire surface of a container before CSS3. Pictures used in <img> tags can be re-dimensioned by width and height attributes, but a background don’t have such attributes. So, if the image is larger than dimensions of container, part of image will fill it’s container, if not – can use tiling for filling the surface, or the image will stay somewhere on the surface…

But is easy enough to solve the problem, based only on what WordPress and Suffusion offer.

1. By CSS3 – the easiest way. Upload your image at Appearance -> Background. At Suffusion Options -> Back-end -> Custom Includes -> Custom Styles add a single line:

With CSS3, for the same selector (body.custom-background), can use multiple background images, as you can see and learn at CSS3 Info.

Pros: The method can be used virtually in any theme – body.custom-background is a WordPress selector, so, will work on any WordPress site. If your theme don’t have a section for defining your styles, can edit the theme stylesheet, or, better, can install a plugin which let you to add or change theme styles – I personally prefer My Custom CSS by Salvatore Noschese (DarkWolf).

Cons: The background-size property is supported in IE9+, Firefox 4+, Opera, Chrome, and Safari 5+, so, in older browsers the image will not be adjusted.

2. The old school way. Do you remember? We can redimension an image used in foreground (in <img> tags). Copy header.php from Suffusion folder to your child theme folder. Open the new file and add a new div, which will contain the full image, immediately before the tag <div id=”wrapper” class=”fix”>. The new code need to look like:

 As you can see, we already add the image with adaptable width and height. Now remain only to format the new div. Go at Suffusion Options -> Back-end -> Custom Includes -> Custom Styles and add this lines:

Done, you have now a fixed background constructed from only one image which will be adjusted for any screen. Of course, the background need to be fixed, otherwise the height of picture will be as the viewport height at page loading, but cannot be adjusted anymore when scroll the page. But is a good sense restriction, images can not be stretched no matter how much.

Pros for the method? The background will be filled in all to-day browsers… Cons? Maybe the method is a little difficult as implies to edit a php file…

But if you use a child theme is safe to edit the file and to revert to the original file from parent folder if something goes wrong… Not saying that the header.php file from your child theme will stay safe and will produce the intended result even if you upgrade Suffusion. And how hard can be to have a child theme of Suffusion? See here: https://drafie-design.nl/3-5-easy-steps-for-creating-a-child-theme-of-suffusion/

https://drafie-design.nl/full-background-image-in-suffusion/trackback/Trackback URI:  

Ciprian

Experienced web developer and graphic designer. Former consultant for Suffusion theme and former moderator on Suffusion Support forum. I teach others while learning myself.

Google+ Profile

    Google+ Page

 Leave a Reply

(Your comment will be published. To contact me privately, use the contact form.)

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  4 Responses to “Full Background Image in Suffusion”

Comments (2) Pingbacks (2)
  1. […] Sometimes is required to add some elements/javascripts/styles in   section of your site. In this case can copy header.php into your child theme then edit this copy. An example of this usage can see in this post: http://www.drafie-design.nl/full-background-image-in-suffusion/ […]

     
  2. […] Full Background Image in Suffusion […]