• Hi!

    Is it possible for me to add a class to an img tag.

    You know, I want to add a background image behind the picture BUT the background image will resize automatics if the image is smaller.

    S?… Can I add a class to the image?

    Thanks //WebbHelp

Viewing 4 replies - 16 through 19 (of 19 total)
  • Thread Starter webbhelp

    (@webbhelp)

    It is like this.

    It is not my blog, so… When the author is writing a new post, AND add an image, then I want that it automatically adds a frame behind the image.

    The frame doesn’t need to be resizeable (automatically), I can use only one frame.

    So every time the author adds a picture in the post, it will be a frame behind the picture.

    Thanks ??

    You could put something like this in your stylesheet:

    .post img {
      background: url(path/to/your/frame-image);
    }

    but that would depend on how the site has been structured.

    Peter

    Thread Starter webbhelp

    (@webbhelp)

    But if I use background, I need to put som width and height, and that change the image width and height to.

    Thanks for helping me, very nice ??

    If you put this in one of my sites:

    .post img {
    background-color:#FF0000;
    padding:10px;
    }

    then I get a nice red 10px wide border around my images, regardless of how big my image is. It just puts a red background color behind the picture, and adds 10px on each side padding to the picture.

    The trick here would be to create an image for a frame, that is a bit larger than the picture that’s going to be inserted, and add the padding to the picture.

    If you want it to look like a real frame, then you might face the problem of the inserted picture: it has to be specific in size (but you could do that with width and height).

    Peter

Viewing 4 replies - 16 through 19 (of 19 total)
  • The topic ‘Add class to image’ is closed to new replies.