Treehouse: Grow your CSS skills. Land your dream job.

How can I reference an Img in a Script?

  • # February 19, 2013 at 12:01 pm

    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:

    # February 19, 2013 at 12:05 pm

    .widget-content img {
    max-width: 100%;

    # February 19, 2013 at 12:09 pm

    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?

    # February 19, 2013 at 12:15 pm

    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)?

    # February 19, 2013 at 12:22 pm

    @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.

    # February 19, 2013 at 12:25 pm

    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.

    # February 19, 2013 at 12:35 pm

    @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.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.