Window Resize/Mobile Browser Background Bugs

Background Bugs Last week I noticed something very odd on Blue Anvil when resizing the browser window; after some casual browsing I discovered it was not just my site with the problem and that it was quite widespread on many ‘web 2.0′ style sites.

The problem occurs when resizing the browser window; cutting off background images and potentially making text illegible. Worse still, the bug also seems to affect mobile browsers with a zoom function, such as opera mobile.

After some dabbling I found a solution, which I shall explain in this post.

The sites that are most affected are those that use ‘content strips’ as I like to call them; that is a full width background with content centered down the middle. I tend to code a ’strip’ like this:

1
2
3
4
5
<div id="header">
     <div class="inner">
          ...Content goes here...
     </div>
</div>

In this example #header is a block level element making it full width with a background image (usually tiled). .inner is my content div; it has a width set and auto-margins to make it centered on the page. The diagram below shows the structure of the layout on blue anvil:

Layout Diagram

If you make the window smaller and then use the horizontal scrollbar in the browser window you will notice the background gets ‘cut-off’. This seems to affect all modern browsers. From what I can gather, it seems the divs with the background image resize with the browser window, meaning any fixed width content will spill out and be shown on the page background; this demo page has the bug for you to see.


The problem itself is not major for most people, since (I assume) resizing the window and scrolling is quite rare. However I have noticed it happening before on the Nintendo Wii browser, and some mobile browsers (opera mobile for instance) where the problem can be more severe; its more of a problem on these devices because It can prevent the user from being able to read content. For example, when opera mobile cut the background off of the footer on Blue Anvil the white text was not legible, as this screenshot shows (taken from my HTC Diamond using Opera Mobile before I fixed the layout):

Bug on Opera Mobile

I experimented with all sorts of attempted fixes; wrappers, 100% widths, clearing…nothing seemed to work at first. In the end I found a workable solution which was actually quite simple: min-width. Using min-width on the div with the background prevented the browser from shrinking it too much hence eliminating the problem.

Fixed Bug

This fix is quite simple and does not seem to affect anything else on the page or cause any issues of its own, so it is something which can be added easily to any layout suffering from this problem.

Enjoy.

Found this post useful? Why not buy me a coffee!

Related Entries

6 Responses to “Window Resize/Mobile Browser Background Bugs”

RSS feed for comments on this post.

  1. D Martin says:

    I came across the exact same issue when designing my latest blog. I banged my head for a solid hour before figuring out “min-width”.

    ReplyReply

    Comment made on July 18, 2008 at 1:48 pm

  2. Mike Jolley says:

    Similar to me then; its very obscure and hard to notice.

    ReplyReply

    Comment made on July 18, 2008 at 5:31 pm

  3. sunny says:

    solved my problem. Thanks.

    ReplyReply

    Comment made on October 24, 2008 at 12:43 pm

  4. Paul says:

    Hey dude, your blog is awesome. Appreciate people like you in this day and time of a changing of the reigns in web styling.

    ReplyReply

    Comment made on January 31, 2009 at 11:58 am

  5. Marcy Sutton says:

    Thanks for the tip! Very informative and I really appreciated the visual demo. It helped me diagnose my problem as being what you described.

    However, be aware that min-width is not supported in IE6, which still has at least 12% of the market share.

    ReplyReply

    Comment made on October 26, 2009 at 5:05 pm

  6. webguy says:

    http://www.kbcafe.com/csharp/?guid=20051222122720

    #usethis{
    min-width: 450px;
    width:expression(document.body.clientWidth &lt; 762 ? &quot;740px&quot; : &quot;100%&quot; );}

    ReplyReply

    Comment made on February 17, 2010 at 2:40 pm

Leave a Reply

Why ask?

About this site

Blue Anvil is the online web design journal & portfolio of , a web designer from Norfolk, England. Read More »
ThemeSlice
  • Featured work - More

    • Beefjack
    • Integrity
    • theotaku.com
  • Latest Tweet - More

    • Would be nice is people showed more love for MiniCard by rating it on wordpress.org http://wordpress.org/extend/themes/minicard
  • Out of the blue - More

    • MiniCard 1.1.7 Update

      I have just uploaded 1.1.7 of MiniCard here and to the WordPress theme directory. This updates includes:

      • New networks; xing, gowalla, yelp, foursquare, mobileme, google buzz
      • A way to change link text and define multiple links of the same network
      • A way to define your own custom links + icons
      • Improved admin panel

      Hope you like it, and don’t forget you can show your support by purchasing the premium pack from here.

    • Switched: From Shared to VPS

      It’s been about two weeks now since I made the transition from a shared reseller hosting account to a VPS (Virtual Private Server) account – impressions so far, excellent performance but fiddly to configure.

      The reason I wanted to change from shared hosting was the fact the server was always being hacked (even though ALL my scripts were secure), there was frequent downtime, support blamed me for problems every time, and it was slow as hell.

      Those used to a shared hosting environment would probably not know where to start when faced with configuring a VPS. Luckily, a lot of it was pre-configured when I received my account – certainly some of the major security holes were patched. I was not satisfied with those however. As a victim of hacking in the past (previous host swears it was not there fault, something I don’t believe) I took extra care to secure it as a much I could – configuring brute force detection, the firewall, installing mod security (excellent rules for that here: http://www.atomicorp.com/wiki/index.php/Atomic_ModSecurity_Rules) and going though multiple guides (like this one: http://www.webhostingtalk.com/showthread.php?t=468168) with a fine-tooth comb.

      The result? My pages are loading at least 6 times faster, I have had no down time (or at least have not noticed any), and I feel in control and happy. No longer am I at the mercy of shared hosts :)

      If your interested, I chose ServInt as my provider as they offered a great deal, as well as being a managed service (so I’m not on my own if I screw things up). I was tempted by the bells and whistles of Media Temple, but felt the ServInt service was better value.

    • Download Monitor 3.2.2 Maintenance Release

      Download Monitor has received some more love and has been updated. Here’s the change log from the new version:

      • Small bugfix in uploader.php – cat ID
      • Changed stats graph calculation – thanks lggemini
      • Changes to headers in download.php to avoid caching
      • File Browser fixes – $root was clashing with something….
      • exclude_cat works in all sections of download_page now
      • Removed hardcoding of /uploads/
      • Added action to download.php – should be able to use it to stop a download if you want – maybe limiting downloads per day or something? Whatever you want…
      • Made it so if you post new file on ‘edit’ screen, the post date is updated.
      • Fixed the ‘blank meta’ section which blanks out custom field values when nothing is set.
      • Moved ‘allow_url_fopen’ check.
      • Someone said downloads don’t work with spaces in the name. They do! Wasting my time sonny…
      • All work and no play make jolley a dull boy
      • Had to rename capabilities so they work. Apologies if you have to set this up again! Cheers to Mark Dingemanse.
      • {category_ID} custom format tag added. Useful if you want to send someone to its category on the DL page I guess. Also added {category_other} so when no category is set “other” is shown – this is because the download page can show an ‘other’ section if you want it to.
      • You can now manually edit the post date on the edit download screen.

      If you have edited capabilities for download monitor user permissions, you’ll have to again sorry! This is because I named them too long. Also, you should check your forced downloads still work because there was a logic error meaning they may not have been forced after-all…

      Enjoy.

    • Mahousive update to Download Monitor (3.2)

      Today I completed the update for the Wordpress Download Monitor Plugin – many tweaks, fixes, and features added. There were no changes to the database structure so people upgrading should be fine. Here is the list from the change log:

      • {user} tag added for custom formats
      • ‘autop’ option fix
      • Download page buttons applied with CSS so they are easier to customise/translate.
      • Fix for pagination bug after editing a download
      • Category output fix on edit downloads screen
      • Category urls on download page use ID rather than name to prevent errors when cats have the same names.
      • exclude_cat added to download_page shortcode
      • Localised ‘hits’ ‘date’ ‘title’ on download page
      • Option to disable the download logging
      • Read file ‘chunked’ some people found large files were corrupted so this should help (fingers crossed)
      • Added show_tags option to download page – displays x amount of tags on the download page.
      • File Browser root setting and download.php logic/mime types modified thanks to Jim Isaacs (jidd.jimisaacs.com)
      • Interface Improvements
      • Bulk edit categories, custom fields, tags, member only downloads
      • Added roles for download monitor admin – should be able to use with a role manager plugin if you want anyone other than admin to access the admin section e.g. http://wordpress.org/extend/plugins/capsman/
      • Change redirect after add
      • Edit Cat names/parents
      • Dedicated tags and thumbnails fields (they still use meta table though)

      And yes, those category link bugs are fixed at long last, and you can edit category names finally. Phew!