treehouse : what would you like to learn today?
Web Design Web Development iOS Development

How can I reference an Img in a Script?

  • Hello. I have gotten an ad script to work on my blog site, but I need to change the image size. I have been using the same script for a month now and usually when I need to do this I go to PS and change them manually, however I was wondering if I could set the size with CSS? Here is a link to my blog: http://random.therandy.tk/

  •   .widget-content img {
          max-width: 100%;
      }
    
  • Couldn't you set the image dimensions in JavaScript when loading the ad (via element.width =) using the name of adBanner to select it or am I missing something?

  • Hmm I haven't changed the widths of the images, but I did move it over, by putting a div style. How does it look(and load)?

  • @chrisburton has the answer for doing it via CSS (though I'd also put height: auto;).

    But @tomrogers123 is getting a little closer to the real problem, I think. If you're using a service to display the ads, you should be able to tell it what size to deliver the ads in.

  • Scratch that. It all works fine now. I found that just moving the ad over works for me as far as the site is concerned. Thank you all for your help.

  • @Tensville Moving it over sort of breaks the whole appearance of the layout. It doesn't look as appealing if you'd actually scale it down to fit the area.