|
|
Background Fit Any Resolution - hmmm | ||
Discussion by complexity with 10 Replies.
Last Update: December 10, 2009, 10:57 pm ( View Rated (1) ) | |||
![]() |
|
|
CODE
<body bg="url.img">
you need it fit any resolution.your backgroud must be so little then it can expand your screen.
QUOTE (complexity)
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.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.
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 resolution
- Set the generated image as background image
- Send 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
CODE
body {background-image: url(your-background.image);
background-repeat: repeat;
}
CODE
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
CODE
<script type="text/javascript"src="/index/homepage.js"></script>
right before your main content in the homepage. Then make this file:
CODE
document.write("</div>");
Name it divclose.js. Place the following code after your content:
CODE
<script type="text/javascript"src="/index/divclose.js"></script>
This is untested, but I am almost positive it would work.
hai 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
hai 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
I 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#388817
-reply by Brad
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!
QUOTE (bjrn)
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 resolution
- Set the generated image as background image
- Send all data to the user.
Link: view Post: 152860
Similar Topics:
Desktop Resolution
calculate image resolution
I Just Installed Smf Image Backgr...
Table Width Help table width="100%" goes off screen (2)
|
(7) Html Cool Codes?
|
Loading...
HOME 






