1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

image size for multiple images?

Discussion in 'CSS' started by Lpspider, Jul 11, 2005.

  1. #1
    Okay, I am very new to CSS, and I'm having a sort of problem. I have one image I want to be large and several others I wish to be small. Whenver I add a image piece into the style sheet it will make ALL images that size...how do I change the size for the images individually?
     
    Lpspider, Jul 11, 2005 IP
  2. Lpspider

    Lpspider Well-Known Member

    Messages:
    2,216
    Likes Received:
    56
    Best Answers:
    0
    Trophy Points:
    160
    #2
    Basically, how do I set the size, posistion, etc of individual images?
     
    Lpspider, Jul 11, 2005 IP
  3. Lpspider

    Lpspider Well-Known Member

    Messages:
    2,216
    Likes Received:
    56
    Best Answers:
    0
    Trophy Points:
    160
    #3
    come on people...
     
    Lpspider, Jul 12, 2005 IP
  4. nevetS

    nevetS Evolving Dragon

    Messages:
    2,544
    Likes Received:
    211
    Best Answers:
    0
    Trophy Points:
    135
    #4
    you should not be using css to set image sizes. You should be setting the attributes in the img tag (height and width), and for best results your images should be actually sized accordingly.

    If you set a picture to 80x60 and it's actually an 800x600 image, the user will have to download the full sized 800x600 file in order to view it as an 80x60 image - and you are trusting the browser to resize the image for you, which isn't a good thing.
     
    nevetS, Jul 12, 2005 IP
  5. Lpspider

    Lpspider Well-Known Member

    Messages:
    2,216
    Likes Received:
    56
    Best Answers:
    0
    Trophy Points:
    160
    #5
    hmm...thanks. Well, how do I position images (with more than one image)?
     
    Lpspider, Jul 12, 2005 IP
  6. Lpspider

    Lpspider Well-Known Member

    Messages:
    2,216
    Likes Received:
    56
    Best Answers:
    0
    Trophy Points:
    160
    #6
    come on people...I know this is basic, but I want to learn. I've looked up many tutorials and non give any background on this. How can I have one image with one position and another with another, etc?
     
    Lpspider, Jul 12, 2005 IP
  7. frankm

    frankm Active Member

    Messages:
    915
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    83
    #7
    You could do something like
    
    <img src="big.gif" class="bigimage">
    <img src="small1.gif" class="smallimage">
    <img src="small2.gif" class="smallimage">
    <img src="small3.gif" class="smallimage">
    
    Code (markup):
    and in your CSS file
    
    .bigimage { width: 500px; height: 500px }
    .smallimage { width: 100px; height: 100px }
    
    Code (markup):
    or similar
     
    frankm, Jul 12, 2005 IP
  8. Lpspider

    Lpspider Well-Known Member

    Messages:
    2,216
    Likes Received:
    56
    Best Answers:
    0
    Trophy Points:
    160
    #8
    Thank you. That's what I was looking for for the most part...but now I've come across another problem.

    Some of the images I wish to position are using javascript onMouseOver to switch between images...and whenever I assign it a class and position it doesn't onMouseOver and it isn't positioned. Help would be appreciated.

    CSS code;

    
    .home
    {
    position:absolute;
    top:100px;
    left:450px
    }
    
    Code (markup):
    JavaScript code;

    <a href="" onMouseOver="document.pic1.src='myimages/home.bmp' class='home'"
            onMouseOut="document.pic1.src='myimages/home2.bmp' class='home2'">
        <img src="myimages/home2.bmp" border=0 name="pic1"></a>
    Code (markup):
    Thanks again
     
    Lpspider, Jul 13, 2005 IP
  9. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Group your images and use CSS classes or IDs for individual images. For example:

    CSS:
    img.small {width: 40px; height: 40px;}
    img.large {width: 100px; height: 100px;}
    img#img1 {width: 123px; height: 123px;}

    HTML:
    <img class="small" ...>
    <img class="small" ...>
    <img class="large" ...>
    <img id="img1" ...>

    J.D.
     
    J.D., Jul 14, 2005 IP
  10. Lpspider

    Lpspider Well-Known Member

    Messages:
    2,216
    Likes Received:
    56
    Best Answers:
    0
    Trophy Points:
    160
    #10
    that answers my first problem but if you look above (the post before yours) you'll see that I'm using javascript...whenever I asign it a class it doesn't work (when with javascript.)
     
    Lpspider, Jul 14, 2005 IP
  11. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Try this

    <a href=""
    onMouseOver="document.pic1.src='mypicture1.png'; document.pic1.className='home';"
    onMouseOut="document.pic1.src='mypicture2.png'; document.pic1.className='home2';">
    <img src="mypicture.png" border=0 id="pic1"></a>

    J.D.
     
    J.D., Jul 14, 2005 IP
  12. Lpspider

    Lpspider Well-Known Member

    Messages:
    2,216
    Likes Received:
    56
    Best Answers:
    0
    Trophy Points:
    160
    #12

    no luck...
     
    Lpspider, Jul 14, 2005 IP
  13. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #13
    If you want people to help you, you should be more specific.

    Anyway, you must be using IE (I guess, I should've figured this out from your BMPs). Use this:

    <a href=""
    onMouseOver="document.getElementById('pic1').src='mypicture1.png'; document.getElementById('pic1').className='home';"
    onMouseOut="document.getElementById('pic1').src='mypicture2.png'; document.getElementById('pic1').className='home2';">
    <img src="mypicture.png" border=0 id="pic1"></a>

    J.D.
     
    J.D., Jul 14, 2005 IP
    Lpspider likes this.
  14. Lpspider

    Lpspider Well-Known Member

    Messages:
    2,216
    Likes Received:
    56
    Best Answers:
    0
    Trophy Points:
    160
    #14
    Thank you very much---your help is greatly apprecaited. I got it working now.

    Oh, and just a side note--- I'm using AOL and not IE...and I'll change redo the pics soon to png.'s. I was just trying to get it work for now.

    thanks again!
     
    Lpspider, Jul 14, 2005 IP
  15. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #15
    AOL is probably using IE internally anyway.
     
    J.D., Jul 14, 2005 IP
  16. Lpspider

    Lpspider Well-Known Member

    Messages:
    2,216
    Likes Received:
    56
    Best Answers:
    0
    Trophy Points:
    160
    #16
    well, I guess I spoke too soon....

    It'll show an 'x' on the left and then when I go over it the image will appear where I want it as will the onMouseOver image. But when I first load the page all of the images appear in the square with the x (I beleive which is used to indicate broken links)
     
    Lpspider, Jul 14, 2005 IP
  17. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #17
    Yes, it's a broken link. Check your paths to the image files.
     
    J.D., Jul 14, 2005 IP
  18. Lpspider

    Lpspider Well-Known Member

    Messages:
    2,216
    Likes Received:
    56
    Best Answers:
    0
    Trophy Points:
    160
    #18
    well there aren't any broken links though---they're correct. I've doulbe and tripple checked them.

    Besides, it wouldn't show the images after hovering over the 'x' if it was a broken link (would it)

    *sigh*
     
    Lpspider, Jul 14, 2005 IP
  19. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #19
    Try it with another browser. If it doesn't work, post your resulting HTML and I will take a look at it.

    J.D.
     
    J.D., Jul 14, 2005 IP
  20. Solicitors Mortgages

    Solicitors Mortgages Well-Known Member

    Messages:
    2,217
    Likes Received:
    139
    Best Answers:
    0
    Trophy Points:
    103
    #20
    or try uploading the images ;)
     
    Solicitors Mortgages, Jul 14, 2005 IP