complexity 0 Report post Posted June 16, 2005 Is it possible to do with html. I have found a few solutions but they dont seem to work. I know it is possible in java. But anyone have the code for html? Would really appreciate it. Share this post Link to post Share on other sites
rvovk 0 Report post Posted June 16, 2005 Isn't it just: background: url(yourimage.jpg); Share this post Link to post Share on other sites
guangdian 0 Report post Posted June 16, 2005 <body bg="url.img"> you need it fit any resolution.your backgroud must be so little then it can expand your screen. Share this post Link to post Share on other sites
sxyloverboy 0 Report post Posted June 17, 2005 Is it possible to do with html. I have found a few solutions but they dont seem to work. I know it is possible in java. But anyone have the code for html? Would really appreciate it. 151613[/snapback] I dont think its actualy possible with just html but i know that you can do it with javascript. i found it on a site once where you just needed to change the url to the image in this code. Its a code that would resize according to the size of the window. but plain html? dont think so. Share this post Link to post Share on other sites
bjrn 0 Report post Posted June 19, 2005 Background images are just like normal images in HTML documents, you can't set them to resize to whatever the user has. You could use some PHP GD functions with some browser sniffing to resize the image before sending it to the client. What you'd have to do is this: When the user comes to your page, check what resolution they are using.Have a PHP function that resizes your background image to the resolutionSet the generated image as background imageSend all data to the user.I am assuming you have some high-resolution image that scales down very well, because most resizing doesn't work very well when there are big changes. I am also assuming your background image doesn't work when you put the image side-to-side, repeating both left-to-right and up-to-down, if that works all you have to do is add body {background-image: url(your-background.image);background-repeat: repeat;} Share this post Link to post Share on other sites
htmlmaster 0 Report post Posted June 23, 2005 No, its not possible, however you are right, it does work in JavaScript, if you require the script then: var jswidth = screen.width;if (jswidth==800) document.write("<div class='main' style='width:63%;'>");else if (jswidth==1024) document.write("<div class='main' style='width:72%;'>");else if (jswidth==1152) document.write("<div class='main' style='width:75%;'>");else if (jswidth==1280) document.write("<div class='main' style='width:77%;'>");else document.write("<div class='main' style='width:63%;'>");Name that file homepage.js for your convienience. Link to this file by using <script type="text/javascript"src="/index/homepage.js"></script>right before your main content in the homepage. Then make this file:document.write("</div>");Name it divclose.js. Place the following code after your content:<script type="text/javascript"src="/index/divclose.js"></script>This is untested, but I am almost positive it would work. Share this post Link to post Share on other sites
bjrn 0 Report post Posted June 24, 2005 Uhm, what good would that script be? It makes a div which is somewhat smaller than the screen it is viewed in. And depending on the contents of the div you might get a clipped or crunched image inside it... Share this post Link to post Share on other sites
iGuest 3 Report post Posted September 6, 2009 how to align in center.Background Fit Any Resolutionhai htmlmaster.., I developed my site in 1024*768 screen resolution, when I looked it in 1280*800 screen resolution it doesn't look the same, some tables looks expanded. Thanks a lot I used your code and now it looks as the same but aligned to left the problem is I want to align it to center in higher resolution. please help.., -question by jananraj Share this post Link to post Share on other sites
iGuest 3 Report post Posted September 6, 2009 how to align in center.Background Fit Any Resolutionhai htmlmaster.., I developed my site in 1024*768 screen resolution, when I looked it in 1280*800 screen resolution it doesn't look the same, some tables looks expanded. Thanks a lot I used your code and now it looks as the same but aligned to left the problem is I want to align it to center in higher resolution. please help..,-reply by jananraj Share this post Link to post Share on other sites
iGuest 3 Report post Posted October 16, 2009 This Works !!!!!Background Fit Any ResolutionI have struggled with the exact same dilemma, however I have recently figured it out. Look no further! Here is the link to the code and CSS: http://stackoverflow.com/questions/376253/stretch-and-scale-css-background/388817%23388817 -reply by Brad Share this post Link to post Share on other sites
nolan 0 Report post Posted December 11, 2009 Depending upon the amount of traffic your site gets, this could be a very bad idea and could upset your web host. By using GD to generate an image that's displayed every single time a user visits your page, you're putting a lot of unnecessary strain on the server's CPU. Imagine if you have a site that gets even 10,000 total page hits a month - that's 10,000 new graphics your website has to create on the fly. As a better option, just use a very highly optimized, large background image that looks pleasant even when a portion of the image is cut off for smaller displays. (This is how most sites with large background images handle it.) Best of luck! Background images are just like normal images in HTML documents, you can't set them to resize to whatever the user has. You could use some PHP GD functions with some browser sniffing to resize the image before sending it to the client. What you'd have to do is this: When the user comes to your page, check what resolution they are using.Have a PHP function that resizes your background image to the resolutionSet the generated image as background imageSend all data to the user. Share this post Link to post Share on other sites