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 5 of 5

Thread: Tile Background

  1. #1
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,928
    Thanks
    46
    Thanked 203 Times in 202 Posts

    Tile Background

    Hi,
    I am attempting to tile my background image. The problem I am having is that the img is too large. I want to modify it's size without having to consult graphic design every time. I was thinking of possibly containing it withing a div element (which I CAN control the size; and then control the image size that way) but I am pretty sure there is no way to use a div as a background-image. Also this is via CSS.

    If anyone knows of a "trick" to modify the size of a background image I would love the help!
    Last edited by alykins; 05-13-2011 at 03:51 AM.

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #2
    Senior Coder
    Join Date
    Aug 2010
    Location
    High Point, NC
    Posts
    3,338
    Thanks
    5
    Thanked 363 Times in 360 Posts
    A div will stretch to the size of the image. You cant "control" an image size with a div. You can resize an image in an image editor. You can also set a size to an image using css, but not a background image.
    Teed

  • #3
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,928
    Thanks
    46
    Thanked 203 Times in 202 Posts
    you can use a div to contain an image... you can set a div size (100px X 100px) and then set the image within it and assign its size to 100% of the containing element. I guess you could also do this by assigning img size, but i like to think of things as blocks on my page... i guess though that is a "no" you can't do some trick to manipulate the img to the size u want?

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #4
    Senior Coder
    Join Date
    Aug 2010
    Location
    High Point, NC
    Posts
    3,338
    Thanks
    5
    Thanked 363 Times in 360 Posts
    Dont confuse "containing" an image with "controlling" an image size. A div will not control an image. If you set a height and width to a div, then place an image inside that div thats larger than the div size, it will break your box model.

    There maybe ways to automatically resize images using js or even a server side. I think Coldfusion has a cfimage tag with some sizing attributes, but I think its best to size your images before using them in your code. That way you dont run the risk of distortion, nor do you run the risk of longer page load times and way more code than you need.
    Last edited by teedoff; 05-13-2011 at 03:55 AM.
    Teed

  • #5
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,928
    Thanks
    46
    Thanked 203 Times in 202 Posts
    gotchya

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE


  •  

    Posting Permissions

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