background-image

Changing background image using jquery

和自甴很熟 提交于 2019-11-27 23:29:45
I have this jquery code that changes the image of the background on click: $('a.note').click(function(){ $('#full').css('background-image','img/1.jpg'); }); However, it's not changing. Is there something I'm missing? You need to include the url() part of the background-image property. $('#full').css('background-image','url(img/1.jpg)'); 来源: https://stackoverflow.com/questions/4578714/changing-background-image-using-jquery

CSS, background-repeat distance

孤街醉人 提交于 2019-11-27 22:55:17
I want to set a background-image but with an specific distance between the repetitions. For example, I have this image to become a background-image : And I want to fix the repetitions in a pattern like this: Check the JSFiddle playground I'm looking for a CSS3 clean solution, not JS, not extra elements, and so forth. If I have to use very modern CSS3 (un-supported) tricks is ok. I guess the ship has pretty much sailed, but still there is a solution based on data-URI. You can generate an SVG containing your image which has a size greater than the image (e.g. to make the margin 60px just make a

How can I tell when a CSS background image has loaded? Is an event fired?

荒凉一梦 提交于 2019-11-27 22:47:04
I have a sidebar widget that has an image background. Over this is a search input form. I don't want the input to show before the image has loaded. Is there a way to attach an load event handler to CSS background images like normal img elements/objects? I know this could be done on a normal image, but I'd like to keep it as a CSS background because the image is part of a sprite. I am using jQuery, so solutions using jQuery or plain DOM JS are equally good. You could load the same image using the DOM / a hidden image and bind to the load event on that. The browser's caching should take care of

Bootstrap carousel as website background

别来无恙 提交于 2019-11-27 20:48:15
问题 I'm using twitter bootstrap carcass for my web project development. Currently I have full screen background image which I set for the body tag like: body { background: url('Content/images/planet.gif') no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; } It looks nice, and resizing works perfectly when I'm trying to change browser window size. Now I would like to add some visual effects to my website by

Set an Image object as a div background image using javascript

一个人想着一个人 提交于 2019-11-27 20:15:45
I want to load 4 images from background showing a load bar to the client and when the images will be downloaded i want to set them as background images to 4 div blocks. I am looking for something like this. var myImages = new Array(); for(var i = 0; i < 4; i++) myImages[i] = new Image(); //load images using the src attribute //and execute an on load event function where to do something like this. var div0 = document.getElementById('theDivId'); div0.style.backgroundImage = myImage[index]; Is there any way to set a background image using an Image javascript object? You can do something close to

how can I set a background image in code?

限于喜欢 提交于 2019-11-27 19:39:52
问题 If I want to set a image as background on a textBox I can use this code in the axml: <Grid> <Grid.Background> <ImageBrush ImageSource="MyImage.jpg" /> </Grid.Background> <TextBlock Text="Some Text" /> </Grid> However, I am creating a TextBlock in code, I amtrying this: TextBox myTextBox = new TextBox(); But in this way I don't know how to access to the ImageBrush property. Which is the way to add a background in code? Thank so much. 回答1: Provided that MyImage.jpg is a file in the application

Is there a way to set background-image as a base64 encoded image?

我只是一个虾纸丫 提交于 2019-11-27 19:14:27
I want to change background dynamically in JS and my set of images is in base64 encoded. I try: document.getElementById("bg_image").style.backgroundImage = "url('http://amigo.com/300107-2853.jpg')"; with perfect result, yet I fail to do the same with: document.getElementById("bg_image").style.backgroundImage = "url('data:image/png;base64,iVBORw0KGgoAAAAAAAAyCAYAAAAUYybjAAAgAElE...')"; nor document.getElementById("bg_image").style.backgroundImage = "data:image/png;base64,iVBORw0KGgoAAAAAAAAyCAYAAAAUYybjAAAgAElE..."; Is there any way to do it? Ezequiel Gorbatik I tried to do the same as you,

How can I set fixed position Background image in jquery mobile for iPhone app using Phonegap

爷,独闯天下 提交于 2019-11-27 18:38:58
问题 I am doing a iPhone app using Phonegap & also using jquery mobile. I want to set background image for data-role=page div. In this height of page is equal to screen & hence background is set to size of screen. But the page content length is much greater than screen & hence gray background is seen after image completes. My question is whether there is a way so that we can keep the background image fixed & scroll or move only content of page & not background image. Just to mention I have tried

Animate CSS background-position with smooth results (sub-pixel animation)

感情迁移 提交于 2019-11-27 18:24:01
I'm trying to animate the background-position of a div, slowly, but without it having jerky movement. You can see the result of my current efforts here: http://jsfiddle.net/5pVr4/2/ @-webkit-keyframes MOVE-BG { from { background-position: 0% 0% } to { background-position: 187% 0% } } #content { width: 100%; height: 300px; background: url(http://www.gstatic.com/webp/gallery/1.jpg) 0% 0% repeat; text-align: center; font-size: 26px; color: #000; -webkit-animation-name: MOVE-BG; -webkit-animation-duration: 100s; -webkit-animation-timing-function: linear; -webkit-animation-iteration-count: infinite

Get final size of background image

不问归期 提交于 2019-11-27 18:05:44
问题 is there an easy way to get the final height and width of a background image with Javascript or jQuery even if a background-size property was applied? I mean, I know I can get the background image url and load it to an Image object and then get the width and height. But it is the size of the source image. If someone scaled it with CSS then the size changed How can I find its final size? @edit it is different from the question marked as similar because it doesnt say how to get the size in