Results 1 to 7 of 7

Thread: automatic size of images

  1. #1
    Join Date
    Sep 2009
    Location
    Asti, Piemonte, Italy
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default automatic size of images

    Dear all,
    I need to have images auomatically sized at 48% of the width of the container. I used this on my CSS
    Code:
    img.sidepic {
    				border-style: double;
    				border-color: #1A3491;
    				float: left;
    				width: 48%;
    				margin-right: 2px;
    }
    the problem is that sometime the images are not sized proportionally in height and thus appear as deformed.
    someone can help me?
    you can see this on www.mccollection.it
    Last edited by djr33; 09-23-2009 at 11:48 PM.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Why not just add height: 48%;?
    If you want width and height equal, that seems fine to me. I'm not sure about the specifics of using CSS to size images proportionally, but it might vary by browser, etc., so specifying both won't hurt anything.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Sep 2009
    Location
    Asti, Piemonte, Italy
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    already tried,
    height= 48% size the image at 48% of the container and not 48% of the image therefore the deformation is also higher...
    I need the image being large 48% of the container and height remain proportional

  4. #4
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    I thought that normally if you declared a percentage width or height then the browser scales the image proportionately.

    You only need to declare one these dimensions, try height="48%", without the width declaration, and see what that does

  5. #5
    Join Date
    Sep 2009
    Location
    Asti, Piemonte, Italy
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thank you very much but my problem is that, declaring only the width, some of the images are not scaled proportionally (especially the ones longer than larger appear as flattened)
    may you help me?

  6. #6
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    Perhaps your problem is not in your CSS but in your HTML.

    You are using CSS to change the width of the image to be 48% of the original.

    I see however that you are also setting the height and width attributes of the <img> tag. Try not setting these attributes, or ensure that the values you enter are proportional.

  7. #7
    Join Date
    Sep 2009
    Location
    Asti, Piemonte, Italy
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    ciao,
    I checked: my HTML in local has not width and height on image, just the class="sidepic".
    I'm using sharepoint designer to publish the web-site.
    I don't understand why on the HTML code on the web there are width and height ...

Bookmarks

Posting Permissions

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