Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jul 2011
    Posts
    105
    Thanks
    12
    Thanked 1 Time in 1 Post

    Scaling Background Images?

    Is it possible to scale DIV background images as the user zooms the site if the site uses EM units of measurement? I need to do this to stop my design layout falling apart when users resize their text. My designs are very carefully planned and executed, therefore I do not want my pages to look bad in the event of viewers messing with their browser's settings.

    Thanks.

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,092
    Thanks
    23
    Thanked 594 Times in 593 Posts
    I know you can use javascript to obtain the window size and work accordingly, but CSS3 does have a solution.

    html {
    background: url(images/bg.jpg) no-repeat center center fixed;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
    }

    And that works great! But to does depend on original size and the ratios. It tries to keep the ratios the same.
    Last edited by sunfighter; 07-04-2011 at 04:35 AM.


  •  

    Posting Permissions

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