Results 1 to 9 of 9

Thread: Responsive background image

  1. #1
    Join Date
    Apr 2014

    Post Responsive background image

    i need help in making a background image responsive to all available resolutions.i tried backgroung-size:cover; but it doesn't showing all part of image.

    thank you.

  2. #2
    Join Date
    Apr 2014
    background-size: cover; will stretch your image proportionally, but keep in mind that if your resolution is a different proportion than your image, some of your background will be cut off.

    If it is imperative to show the entire background, but you want to keep aspect ratio, background-size: contain; can be an answer, but this often leaves you with blank space due to differences in aspect ratios once again.

    background-size: 100% 100%; will stretch your background to completely fill the parent element, but this may distort your image depending on the screen resolution.

    It is simply a matter of picking your poison, or adjusting your image to fit a particular solution you are happiest with.

  3. #3
    Join Date
    Mar 2012
    One problem with resizing one image to fit the whole range of display sizes is that, to achieve an acceptable quality at the highest size, the image is likely to be slow to load on low-spec mobile devices. One solution is to have two or three sizes of image, with the appropriate one used according to the device width and height. However, there is a problem: If you use client-side techniques to select the appropriate image, the device will download ALL the images even if only the smallest one is needed! Which somewhat defeats the purpose of having different sizes of images. There is a solution, but it involves using server-side code (PHP) to send only the appropriate image according to the larger of the device display dimensions.

  4. #4
    Join Date
    Dec 2012
    background-size: 100% 100% this will work good, but on any phone in portrait mode, it will be stretched a lot, i think you have to remove the background entirely on phones

  5. #5
    Join Date
    Apr 2014
    thank you guys for your replies...

    i keep background -size: 100% 100% for all devices except phone. for phone i used cover so that it will show nicely.

  6. #6
    Join Date
    Apr 2014
    Bhuabneswar, India
    If you want responsive background image then purchase images from stockphoto company. They are providing HD quality photos with more responsive.

  7. #7
    Join Date
    Sep 2006
    new york
    Interesting. Trying to add something to http://www.josephdenaro.com, I used
    html { background: #afeeee url(miscImages/jdMilkyWayCut.gif) no-repeat center center fixed; 
      -webkit-background-size: cover;
      -moz-background-size: cover;
      -o-background-size: cover;
      background-size: cover;  }
    But page was too slow in downloading, even when I cropped image I was using. Is it better NOT to crop the image?

    Following this discussion, I'm going to try background-size: 100% 100%;

    Any advice about improving download would be appreciated. Image is just for abstract color pattern so it does not have to be sharp/clear. Also have JavaScript to switch to mobile version.

    if (screen.width <= 699) {
    document.location = "indexmobile.html";
    Last edited by auntnini; 04-23-2014 at 05:47 PM. Reason: typo

  8. #8
    Join Date
    Mar 2012
    It is always important to optimize images, but particularly with large ones. This can be done with any good picture editor. Basically you save the image as JPEG in a range of qualities (say 80%, 70%, 60%, 50%) then do A:B comparisons of the JPEGs to the original at 2x magnification. Choose the image that has the best compromise of loss of detail vs file size for the particular context. Note: For particularly important images, I'd save the rejected images as well. Just in case the client does not like the compromise you selected. You can then easily substitute a more appropriate one.

    However, re-reading your post, I'm not sure that is the only problem in this case. Using client-side code to suppress the image for mobiles may have little or no effect on the load time. This is because the image may be downloaded even if it is not used. I'd suggest you test a version of the page as-is against a version where the display code is commented out. If the latter is significantly quicker for mobiles, then it suggests that the image is being downloaded even when it is not used. If so, you may need to use server-side code (PHP) to only send the image when it is needed.
    Last edited by jedaisoul; 04-24-2014 at 04:38 AM.

  9. #9
    Join Date
    Sep 2006
    new york
    Thanks jedaisoul. I usually do not JPEG compress at lower %, but you reminded me that this is a case when I should. I thought that cropping the image might do the trick, but is it still too slow so I wonder if making the browser do the extra re-sizing might be as bad as using a larger version. We do not have access to server-side scripting such as PHP.

    I might have to come up with a different way add some background interest -- some kind of CSS3 animation? (See http://www.karensantry.com for example.) The repeated small images I've come up with so far are an annoying pattern.

    I personally liked a plain background (http://www.josephdenaro.com/indexTurquoise.html)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.16968 seconds
  • Memory Usage 2,924KB
  • Queries Executed 15 (?)
More Information
Template Usage (33):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (9)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (71):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates