0

enter image description here

I have a div where an image is generated.result. I need to set a background image within that div that will act as a layer on top of the generated image. I have the following, but can't get the image to show:

image.appendTo($(".result"))
  $button = $('<button class="btn btn-default remove">')
        .text('Remove')
        .on('click', function () {
            image.remove();
            $(this).remove();
            return false;
        });
    $button.appendTo($(".result").css("background-image", "url('iphone_5.jpg') no-repeat").css("z-index", "1000"));
});

The image on the right in the screenshot is the rendered crop. You can see the image in the background(along the top and left border) that should sit on top of the rendered image.

1
  • 1
    Can you please try to rephrase the actual question, it is very unclear what you are trying to achieve. Also there are a few mistakes in your code! But first go for a clearer question! Commented Oct 24, 2014 at 15:26

2 Answers 2

0

You are trying to use the shorthand background syntax with the background-image property. You need to change that to background.

image.appendTo($(".result"))
  $button = $('<button class="btn btn-default remove">')
        .text('Remove')
        .on('click', function () {
            image.remove();
            $(this).remove();
            return false;
        });
    $button.appendTo($(".result").css("background", "url('iphone_5.jpg') no-repeat").css("z-index", "1000"));
});
Sign up to request clarification or add additional context in comments.

3 Comments

This is what I'm looking for. However, I can't get the iphone image to sit on top of the generated image.
That's because it is a background image. Backgrounds go behind the content, not on top of it.
And, I'm having an early morning Friday moment here :)
0

http://www.w3schools.com/css/css_background.asp

body {
    background-image: url("gradient_bg.png");
    background-repeat: no-repeat;
}

or

body {
    background: url("gradient_bg.png") no-repeat;
}

like

image.appendTo($(".result"))
  $button = $('<button class="btn btn-default remove">')
        .text('Remove')
        .on('click', function () {
            image.remove();
            $(this).remove();
            return false;
        });
    $button.appendTo($(".result").css("background", "url('iphone_5.jpg') no-repeat").css("z-index", "1000"));
});

or

image.appendTo($(".result"))
  $button = $('<button class="btn btn-default remove">')
        .text('Remove')
        .on('click', function () {
            image.remove();
            $(this).remove();
            return false;
        });
    $button.appendTo($(".result").css("background-image", "url('iphone_5.jpg')").css("Background-repeat", "no-repeat").css("z-index", "1000"));
});

ahh to slow :c

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.