CSS Image Resize

Discussion in 'CSS' started by Pudge1, Jun 20, 2010.

  1. #1
    
    #layout-container{
      background: url(preview_mario.jpg) no-repeat;
      width: 998px;
      height: 998px;
    }
    
    Code (markup):
    I need to have the background displayed as a 998x998 image but it is a 1280x1280 image. When I use the width/height as 998 it just cuts off part of the image. Can someone help me so it will resize with whatever width/height I set it to?
     
    Pudge1, Jun 20, 2010 IP
  2. graspit

    graspit Peon

    Messages:
    87
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try using this syntax:

    .resize {
    width: 998px;
    height : auto;
    }

    .resize {
    width: auto;
    height : 998px;
    }
     
    graspit, Jun 20, 2010 IP
  3. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #3
    Thanks but still cuts it off
     
    Pudge1, Jun 20, 2010 IP
  4. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #4
    That's the way background images work. If you want to resize, it must be a foreground image. Why don't you simply re-size the image in your image manipulation application? I'd simply use the convert utility from the Imagemagick suite:
    gt@koko:~/public_html$ convert preview_mario.jpg -resize 998x998 preview_mario-998.jpg
    Code (markup):
    You may prefer to use Photoshop or GIMP, but for something this trivial, a cli app is simplest.

    cheers,

    gary
     
    kk5st, Jun 20, 2010 IP
  5. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #5
    Thanks I think I'll do that
     
    Pudge1, Jun 21, 2010 IP
  6. abeltenny0210

    abeltenny0210 Guest

    Messages:
    105
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Just mask a DIV above the image and cut the extra area.
     
    abeltenny0210, Jun 21, 2010 IP